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)

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 15:16:55
Script start
Timing: Jan 18 2025 15:16:55
Module start 'layout'
Timing: Jan 18 2025 15:16:55
Module start 'content'
Timing: Jan 18 2025 15:16:56
Module end 'content'
Timing: Jan 18 2025 15:16:56
Script end

Main resources:

Total runtime1.2455 sec
Peak memory usage4,096.0000 KB
Database Queries64

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 589.0234152.6250
Module start 'layout' 0.00510.0033 741.648439.4453
Module start 'content' 0.00841.2356 781.0938631.6641
Module end 'content' 1.24400.0014 1,412.757812.1719
Script end 1.2454  1,424.9297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2558160.0002
Check MTime0.00140.1096160.0001
Mysql Total
Database connection0.00070.057210.0007
Mysqli_queries1.190495.5772640.0186
Looping result0.00070.0572620.0000
Template Total1.217997.820.6090
Template load0.00200.156720.0010
Template processing1.216097.629720.6080
Template load and register function0.00010.010210.0001
states
state_id_array0.00060.051510.0006
state_identifier_array0.00160.130120.0008
Override
Cache load0.00170.1395450.0000
Sytem overhead
Fetch class attribute can translate value0.00120.096740.0003
Fetch class attribute name0.00120.093360.0002
XML
Image XML parsing0.00110.087340.0003
class_abstraction
Instantiating content class attribute0.00000.000760.0000
General
dbfile0.00080.0622210.0000
String conversion0.00000.003140.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/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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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