Share » Forums » Setup & design » sorting by date field

sorting by date field

sorting by date field

Wednesday 25 October 2006 12:39:16 pm - 3 replies

Author Message

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)

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu