fetch sort_by conditional

Author Message

Lachy Laycock

Saturday 01 November 2003 4:28:11 am

Hi all,
I am trying to fetch data with a conditional in it, but can't work out the sort_by syntax...

I am trying to do this:

Fetch all children of a certain node of a certain class where the value of item.data_map.year.data_int > 2002.

Any ideas?

Thanks,
Lachy

Paul Forsyth

Saturday 01 November 2003 4:39:50 am

Have a read of this doco:

http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/data_fetch

paul

Lachy Laycock

Saturday 01 November 2003 5:06:09 am

Thanks for the reply.

I actually looked at that page before posting. I am afraid, it didn't clear up my confusion:

Here is what I am trying to do:
Fetch all children of node 47 of class 19 where the value of item.data_map.year.data_int > 2002.

fetch( content, list, hash(
parent_node_id, 47,
limit, 3,
sort_by, array( priority, false() ),
class_filter_type, include,
class_filter_array, array( 19 )
attribute_filter( 19, '>', 2002) ) )}

now I assume the attribute_filter() syntax is incorrect, but I am not sure how to get the fetch to match against values in the children nodes...

Any pointers would be much appreciated.

Thanks,
Lachy

Paul Forsyth

Saturday 01 November 2003 5:30:22 am

The problem is likely with your use of the class attribute id. You have:

attribute_filter( 19, '>', 2002)

where it is seems 19 is the class id. but if you look at the doco again this parameter needs to the class attribute id.

What you need to do is look at your class again in the admin and identify the id number for your 'year' attribute. Put this number in your fetch and see if this works.

Btw, do you have debug on? It may be reporting this error.

paul

Lachy Laycock

Saturday 01 November 2003 8:26:08 am

Quite rightly, the docos specify the class attribute id.

In my admin section it reports that my class attribute id is 171:
Year (Integer) (id:171)

so, i modified to suit this:
{let news_list=fetch( content, list, hash(
parent_node_id, 47,
sort_by, array( array( published, false() ) ),
attribute_filter, array('or', array(171, '>=', 2003) ) ) )}

and presto it works! My syntax and my id were wrong.

What makes little sense to me is the need for the "array('or', ...)" part in the syntax, but it works and for the moment that is good enough.

Thanks for the help again!

Paul Forsyth

Sunday 02 November 2003 5:07:22 am

Glad it worked :)

The use of 'array' is just a way of passing the variables from the template language to the underlying php. i think by using an array all the parameters are passed in with a single variable. this helps keep the api interface a little simpler.

paul

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:17:13
Script start
Timing: Jan 18 2025 19:17:13
Module start 'layout'
Timing: Jan 18 2025 19:17:13
Module start 'content'
Timing: Jan 18 2025 19:17:13
Module end 'content'
Timing: Jan 18 2025 19:17:13
Script end

Main resources:

Total runtime0.6134 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 587.9141152.6250
Module start 'layout' 0.00500.0031 740.539139.4453
Module start 'content' 0.00810.6039 779.9844509.1797
Module end 'content' 0.61200.0014 1,289.164112.1641
Script end 0.6133  1,301.3281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.5753160.0002
Check MTime0.00140.2361160.0001
Mysql Total
Database connection0.00080.122610.0008
Mysqli_queries0.552890.1317660.0084
Looping result0.00060.0946640.0000
Template Total0.584795.320.2924
Template load0.00220.365220.0011
Template processing0.582594.962620.2912
Template load and register function0.00030.041910.0003
states
state_id_array0.00080.130610.0008
state_identifier_array0.00150.238220.0007
Override
Cache load0.00200.3183540.0000
Sytem overhead
Fetch class attribute can translate value0.00100.158820.0005
Fetch class attribute name0.00150.246260.0003
XML
Image XML parsing0.00030.044220.0001
class_abstraction
Instantiating content class attribute0.00000.002460.0000
General
dbfile0.00070.1161100.0001
String conversion0.00000.001040.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs