Forums / Setup & design / sorting by date field

sorting by date field

Author Message

risto CMS user

Wednesday 25 October 2006 12:39:16 pm

I have a class that contains a date field. but I cant get the listings sorted by that date.
How doo I go about dooing this?

[code]
<h1>{$node.name}</h1>

{let page_limit=20
children=fetch('content','list',
hash(

parent_node_id,$node.node_id,
sort_by,$node.sort_array,
limit,$page_limit,offset,$view_parameters.offset)) list_count=fetch('content','list_count',hash(parent_node_id,$node.node_id))}

{section name=Child loop=$children sequence=array(bglight,bgdark)}
{node_view_gui view=full content_node=$Child:item}
{/section}
{include name=navigator
uri='design:navigator/google.tpl'
page_uri=concat('/content/view','/full/',$node.node_id)
item_count=$list_count
view_parameters=$view_parameters
item_limit=$page_limit}
[/code]

sort_by,$node.sort_array, -> sort_by, $note.datefield

something like this?

Mark Marsiglio

Wednesday 25 October 2006 5:17:11 pm

This was a fetch we did that is sorted by date:

	        {let newtimestamp=cond( and(ne($view_parameters.month, ''), ne($view_parameters.day, ''), ne($view_parameters.year, '')), makedate($view_parameters.month, $view_parameters.day, $view_parameters.year), currentdate() )
		 theseevents=fetch( 'content', 'list', hash(
			'parent_node_id', 1224, limit, 3,
			'sort_by', array('attribute', true(), '278' ),
	 		'attribute_filter',
			array( 'and', array( '279', '>=', $newtimestamp ), array( '280', '!=', 1 )) ) ) }

278 is the class attribute ID of "start date" of our event class for sort
279 is the class attribute ID of "end date" of our event class to filter past events
280 is a checkbox to exclude from this list

Let me know if that is enough code sample to make sense here...

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

B. Vollmer

Wednesday 04 April 2007 5:00:01 am

I used this code snippet for my event database. But the code didn't work for me.

ez Debug only says: Notice: Attribute filter returned false.

For more debugging, I displayed the value of $newtimestamp in the page and compared it directly with the values in the database. There are 4 objects that match the criteria, but why the fetch-function didn't get them?

My Code:

{let newtimestamp=cond( and(ne($view_parameters.month, ''), ne($view_parameters.day, ''), ne($view_parameters.year, '')), makedate($view_parameters.month, $view_parameters.day, $view_parameters.year), currentdate() )

                 termine=fetch( 'content', 'list', hash(

                        'parent_node_id', 77, limit, 3,

                        'sort_by', array('attribute', false(), '200' ),

                        'attribute_filter', array( '200', '>=', $newtimestamp )) )
}	
 

Osichr Hayez

Tuesday 02 October 2007 1:50:12 am

I do this by the same code as Mark proposes:

{def $kurs=fetch( 'content', 'list',hash(
    'parent_node_id', 251,
    'class_filter_type', "include",
    'class_filter_array', array(18),
    'sort_by', array('attribute', true(), '230' )
) )}

Where 230 is my date-field in my custom class object.(Class 18 in my case)

eZ debug

Timing: Jan 18 2025 10:39:23
Script start
Timing: Jan 18 2025 10:39:23
Module start 'content'
Timing: Jan 18 2025 10:39:24
Module end 'content'
Timing: Jan 18 2025 10:39:24
Script end

Main resources:

Total runtime1.4871 sec
Peak memory usage4,096.0000 KB
Database Queries201

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.8203180.8438
Module start 'content' 0.00691.3575 769.6641636.7422
Module end 'content' 1.36440.1226 1,406.4063337.3828
Script end 1.4870  1,743.7891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.2764210.0002
Check MTime0.00170.1117210.0001
Mysql Total
Database connection0.00090.060310.0009
Mysqli_queries1.407394.63782010.0070
Looping result0.00200.13261990.0000
Template Total1.443897.120.7219
Template load0.00200.137520.0010
Template processing1.441796.950420.7209
Template load and register function0.00010.008510.0001
states
state_id_array0.00550.366610.0055
state_identifier_array0.00080.053720.0004
Override
Cache load0.00170.1161450.0000
Sytem overhead
Fetch class attribute can translate value0.00140.096150.0003
Fetch class attribute name0.00110.074760.0002
XML
Image XML parsing0.00140.097050.0003
class_abstraction
Instantiating content class attribute0.00000.000760.0000
General
dbfile0.00350.2376320.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs