How to fetch content by the custom property in php

Author Message

xiaoshitou xiaoshitou

Sunday 21 March 2010 11:46:45 pm

I create a custom class that names "News" and it own a property calls "Date", in tpl, i can fetch the content sort by date as follow:{set $children=fetch( content, list, hash( 'parent_node_id', $object.main_node_id, 'limit', $limit, 'offset', $offset, 'language', $currentlanguage, 'sort_by', array( 'attribute', false(), 'news/date' ) ) ) }but how to fetch it sort by date in php? I try several ways but not correct:$sort = array( 'attribute', true, 'date' );$treeParameters = array ('Offset' => false,'OnlyTranslated' => false,'Language' => $countryCd,'Limit' => false,'Limitation' => null,'class_id' => false,'SortBy' => $sort,'AttributeFilter' => false,'ExtendedAttributeFilter' => false,'ClassFilterType' => "include",'ClassFilterArray' => false,);or$treeParameters = array ( ......'SortBy' => array( 'attribute' => 'News/Date' ),......);or$treeParameters = array ( ......'SortBy' => array ('News/Date','Ascending'),......);Anyone who knows that please help me, many thanks!

Norbert Wagner

Monday 22 March 2010 3:34:03 am

Hi xiaoshitou,
please use code blocks when you write code in the forums.

To your question:

array('SortBy' => array('attribute', true, 'news/date'))

should work.

Not sure if you tried this, though.

Regards,
Norbert

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 10:21:31
Script start
Timing: Jan 18 2025 10:21:31
Module start 'layout'
Timing: Jan 18 2025 10:21:31
Module start 'content'
Timing: Jan 18 2025 10:21:32
Module end 'content'
Timing: Jan 18 2025 10:21:32
Script end

Main resources:

Total runtime0.8373 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 588.0469152.6406
Module start 'layout' 0.00730.0044 740.687539.4922
Module start 'content' 0.01170.8242 780.1797461.1094
Module end 'content' 0.83590.0014 1,241.28918.1250
Script end 0.8372  1,249.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4192160.0002
Check MTime0.00130.1608160.0001
Mysql Total
Database connection0.00130.158710.0013
Mysqli_queries0.795194.9617540.0147
Looping result0.00050.0612520.0000
Template Total0.794894.920.3974
Template load0.00230.272820.0011
Template processing0.792694.659620.3963
Template load and register function0.00020.027010.0002
states
state_id_array0.00280.330810.0028
state_identifier_array0.00150.175220.0007
Override
Cache load0.00190.2328130.0001
Sytem overhead
Fetch class attribute can translate value0.00090.103920.0004
Fetch class attribute name0.00090.111520.0005
XML
Image XML parsing0.00020.026420.0001
class_abstraction
Instantiating content class attribute0.00000.000620.0000
General
dbfile0.00060.0769100.0001
String conversion0.00000.001440.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 11
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs