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.