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.

eZ debug

Timing: Jan 18 2025 19:24:54
Script start
Timing: Jan 18 2025 19:24:54
Module start 'layout'
Timing: Jan 18 2025 19:24:54
Module start 'content'
Timing: Jan 18 2025 19:24:55
Module end 'content'
Timing: Jan 18 2025 19:24:55
Script end

Main resources:

Total runtime1.1882 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0100 587.9375152.6250
Module start 'layout' 0.01000.0042 740.562539.4453
Module start 'content' 0.01421.1722 780.0078536.5781
Module end 'content' 1.18640.0018 1,316.585912.1563
Script end 1.1882  1,328.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.3059160.0002
Check MTime0.00160.1324160.0001
Mysql Total
Database connection0.00080.069010.0008
Mysqli_queries1.130395.1262570.0198
Looping result0.00060.0475550.0000
Template Total1.149796.820.5749
Template load0.00240.200920.0012
Template processing1.147396.557820.5737
Template load and register function0.00020.015410.0002
states
state_id_array0.00090.073510.0009
state_identifier_array0.00150.128520.0008
Override
Cache load0.00200.1674260.0001
Sytem overhead
Fetch class attribute can translate value0.00050.044520.0003
Fetch class attribute name0.00160.133940.0004
XML
Image XML parsing0.00070.058920.0003
class_abstraction
Instantiating content class attribute0.00000.000940.0000
General
dbfile0.00110.0925160.0001
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs