Forums / General / How create a agenda

How create a agenda

Author Message

Francesc Febrer

Friday 23 January 2004 4:45:07 am

Hi.

I want create a agenda with eZPublish. I create a class with different item (name, place and date). But when I want show this class, I want that appaers sorted by date (display the elements more actual) and that the system removes the items expired.

Please, how can I do this?

Thanks.

Sébastien Prud'homme

Tuesday 27 January 2004 12:03:30 pm

I have a web page which display some events. Here is the code to sort by the date attribute of the events:

{let events=fetch(content,list,hash(parent_node_id,$node.node_id,sort_by,array(array
(attribute,true(),156),array(attribute,true(),157))))}

156 corresponds to the id of the class date attribute
157 correspond to the id of the class time attribute

you can use only a datetime attribute if you prefer :
{let events=fetch(content,list,hash(parent_node_id,$node.node_id,sort_by,array(array
(attribute,true(),MY_DATETIME_ID))))}

where MY_DATETIME_ID is the id of your datetime attribute

For removing expired items i don't know yet if you can fetch items with a datetime greater that the current datetime...but you can use a simple "if" statement in the items loop of your template

Anders F

Tuesday 27 January 2004 12:50:50 pm

I use this code to display class "event", sort it by attribute "date" and only display items within 1 month from the current date. Almost positive it works..

{let currentdate=currentdate()
     limitdays=31
     enddate=sum($currentdate, mul($limitdays,24,3600))
     children=fetch( content, list, hash( parent_node_id, CALENDAR_NODE,
                                          sort_by, array('attribute',true(),'event/date'),
                                          class_filter_type, include,
                                          class_filter_array, array( 'event' ) ) )}

<h2>Calendar</h2>

{section name=Child loop=$children}
{section show=and(or($Child:item.data_map.date.content.timestamp|ge($currentdate)),
or($Child:item.data_map.date.content.timestamp|le($enddate)) )}
<p><b>{$Child:item.data_map.date.content.timestamp|datetime( custom, '%D %d %M %H.%i' )}</b><br />

{attribute_view_gui attribute=$Child:item.data_map.body}</p>
{/section}
{/section}
{/let}