Kelly Milligan
|
Monday 22 March 2010 10:56:09 am
Hi, I am trying to write a fetch statement that will fetch a list of articles that have publish dates and unpublish dates that match the following: publish date is <= current date OR is null AND unpublish date is >= current date OR is null is it possible to have multiple attribute filters? or should I return the articles without the date filtering and do this logic in a foreach loop?
|
Kelly Milligan
|
Monday 22 March 2010 11:20:52 am
just to add to the above, I have this working
{def $articles = fetch( 'content', 'list',
hash( 'parent_node_id', 174,
'sort_by', array( 'attribute', false(), 'article/publish_date' ),
'attribute_filter', array('and',
array('article/publish_date', '<=', $timestamp),
array('article/unpublish_date', '>=', $timestamp),
array('article/firstname', '=', $firstname),
array('article/lastname', '=', $lastname )),
'class_filter_type', 'include',
'class_filter_array', array( 'article' ), 'depth', '5' ) )} but want to enable null publish and unpublish dates.
|
Kelly Milligan
|
Monday 22 March 2010 11:38:13 am
ended up with this, but I am hoping that there is a way to build this into the fetch statement {foreach $articles as $article} {if and(or(le($article.data_map.publish_date.content.timestamp, $timestamp), eq($article.data_map.publish_date.content.timestamp, '')),or(ge($article.data_map.unpublish_date.content.timestamp, $timestamp), eq($article.data_map.unpublish_date.content.timestamp, '')))} <li><a href={$article.url|ezurl()} title="{$article.data_map.title.content|wash()}">{$article.data_map.title.content|wash()}</a></li> {/if} {/foreach}
|