Complex attribute_filter in fetch

Author Message

Xavier Portebois

Monday 14 May 2007 1:56:51 am

Hello

In order to make some events agenda, I have to filter objects on many criteria :
* publication dates are valid (i.e., begin publication date before now, and end publication date after now)
* event dates belong to the current month

So I get in a fetch an attribute_filter like this one :

...
'attribute_filter',
	array( 'and',
		array('and',
			array('evenement/date_debut', '<=', currentdate()),
			array('evenement/date_fin', '>=', currentdate())
		),		
	array( 'or',
			array( 'evenement/date_debut_evenement', 'between', array( sum($agenda_first_ts,1), sub($agenda_last_ts,1)  )),
			array( 'evenement/date_fin_evenement', 'between', array( sum($agenda_first_ts,1), sub($agenda_last_ts,1) ))
		)
	),
...

There is so a first AND-condition, which links the two conditions blocks :
* an AND-condition between the publication dates
* an OR-condition between the event dates (variables used are ok)

The problem is that I get a notice <i>"attribute filter returns false"</i>, and there's any fetch result.
I tried the first condition (on publication dates), and I got results. I tried then only the second condition (on event dates), and I got results too ; and finally, I know that they are the same event objects, so linking the two conditions with an AND would still get results.
Besides, when I replace the first AND by an OR-condition, I always get the <i>"attribute filter returns false"</i> message... even each condition returns results !

Any idea ? Maybe I write my attribute_filter in a wrong way ?

Frédéric DAVID

Monday 14 May 2007 2:34:28 am

I don't think it's possible.

But you can search to the attribute extended_attribute_filter.

You can find a simple example here : http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list

Blog : http://www.frefred.fr/blog/ez-publish
feZ Meta Data : http://projects.ez.no/fezmetadata

Xavier Portebois

Monday 14 May 2007 5:05:09 am

Ok, thanks.

Actually, I found a solution by putting one of my condition in the fecth itself, and then, when I use the results in a <i>foreach</i>, I check the second condition with a simple <i>if</i>.

The results is the same, and thanks to the 1st conditional test I shouldn't loose too much efficiency.

Anyway, thanks for your answer !

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.