Forums / Setup & design / Customize calendar.tpl. Fetching content by a date field attribute instead of the default published. How to ?

Customize calendar.tpl. Fetching content by a date field attribute instead of the default published. How to ?

Author Message

laurent le cadet

Saturday 25 September 2004 4:54:30 am

Hi,

I'm trying to use the calendar.tpl, which work fine but what I need is to fetch the the content of a specific node with an attribute instead of the published date.

I created a class with a date field, let us call it "publication_date".
I think it's possible to sort by attribute but I just don't know how.
I presume the date field use the same structure as the published date (2000,00,00) so I change the 'published' by the date field attribute ID (here it's '187'):

    {let log_node=fetch( content, node, hash( node_path, $show_subtree ) )
         show_week=false()
         month_list=fetch( content, tree, hash( parent_node_id, $log_node.node_id,
                                                class_filter_type, include,
                                                class_filter_array, array( 'agenda' ),
                                                attribute_filter, array( and, array( '187', '>=',
                                                                                      $time_start ),
                                                                              array( '187', '<=',
                                                                                      $time_end ) ),
                                                group_by, array( "published", "day" ),
                                                as_object, false() ) )
         month=$month_list|month_overview( 'published', $time_published,
                                           hash( current, $time_current,
                                                 current_class, 'selected',
                                                 today_class, 'today',
                                                 link, $log_node.url_alias,
                                                 month_link, true(), year_link, true(), day_link, true(),
                                                 next, hash( link, $log_node.url_alias ),
                                                 previous, hash( link, $log_node.url_alias ) ) )}
        {include name=Month uri="design:navigator/monthview.tpl" month=$month show_week=$show_week}
     {/let}

But it still working the same way.

Or maybe we have to change the $time_published :
time_published=maketime( 0, 0, 0, $today_info.month, $today_info.day, $today_info.year )

Someone has an idea ?

Laurent

laurent le cadet

Monday 27 September 2004 11:58:36 pm

Is it possible or not ? I really stuck on this....

Paul Borgermans

Tuesday 28 September 2004 12:09:51 am

No,

But there is a contribution which does this:

http://ez.no/community/contributions/applications/agenda_v1_0

It is for including in templates for node views (not pagelayout.tpl, that needs some tweaking)

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

laurent le cadet

Tuesday 28 September 2004 12:17:32 am

Thanks Paul,

Your answer is really clear.
I already had a look at Stefano's template without a great success. I'm going to try again to make it works.

Laurent.

Tore Skobba

Tuesday 28 September 2004 1:26:01 am

Hi

Use the Agenda, it is more flexible then EZ calendar view, the later I find very difficult to use and adapt.. I like the idea very much but I think it is currently to complex and lacking documentation to be of any good use.

For an example of an adapted agenda see: www.grunderskolen.no and alumni.grunderskolen.no

Cheers
Tore

laurent le cadet

Tuesday 28 September 2004 2:19:21 am

Hi Torre,

I managed to reproduce the calendar as you did on alumni.grunderskolen.no by including Stefano template in a pagelayout. First step (Champaign !).
But I have few problems :

- I can't print out the result (content/view/full/...).
Stefano told about a fetch instruction that way :

{let temp_ts=makedate( $view_parameters.month, $view_parameters.day, $view_pa
rameters.year )
events=fetch( 'content', 'list', hash( 'parent_node_id', 247,
'attribute_filter',
array( 'and',
array( 'event/date_from', '<=', $temp_ts
),
array( 'event/date_to', '>=', $temp_ts )
) ) ) }

...but I don't know how to use it.

- The previous/next buttons jump to the home page

- All the days of the current month between the first event and the end of the month are show as a link (even if there is no event).

I'm lost a little...

laurent le cadet

Tuesday 28 September 2004 8:06:10 am

headhach...

I stuck on printing out the agenda result, what and where ?

<b>"Create a new override for results"</b> <i>Stefano</i>

I tryed turning on the debug to print which template is call to display the result of the agenda event but no info.
I tested wiew/full or line whithout ant result.

May I have some help or where can I fund a more consistent doc ?

It's a case of emergency before a nervous breakdown...(look at me on your right)

Laurent

Tore Skobba

Wednesday 29 September 2004 2:32:07 am

You need to do an node override in order to display the agenda template code.. I.e in:

settings/siteaccess/YOURDESIGN/override.ini.append

add something like this:
[agenda]
Source=node/view/full.tpl
MatchFile=node/view/agenda.tpl
Subdir=templates
Match[node]=NODE_NUMBER , the node number of the content object which holds all the calendar events

laurent le cadet

Wednesday 29 September 2004 3:16:11 am

Hello Tore,

It was already done (full and line) but without the node ID...I add the line, claer all caches, but no way :(

Actually :

- the agenda display links from the first event record with the date_from attribute till the end of the month.
- the links relative to the day I created events (not the date_from attribute) show agenda view as lines
- previous/next buttons jump to the home page

It's a new step (line view) but still not really efficient.

Do you have another idea ?

Laurent.

laurent le cadet

Wednesday 10 November 2004 10:58:16 am

Hi (and sorry) to be back again,

I stopped for a while the site I work on (I was making a CD-ROM), and I'm back again with the calendar V1.

I feel very stupid and frustrate that I can't not achieve this part by myself.
The calendar works very well (date_from, date_to) but the I don't know how to write the template which is call.
I tryed this :

{let temp_ts=makedate( $view_parameters.day, $view_parameters.month, $view_parameters.year )
events=fetch( 'content', 'list', hash( 'parent_node_id', 63, 'attribute_filter', array
( 'and', array( 'agenda/date_from', '<=', $temp_ts), array( 'agenda/date_to', '>=', $temp_ts ) ) ) ) }
{section name=eventsLoop loop=$events}

{node_view_gui view=element content_node=$eventsLoop:item}

{/section}
{$temp_ts}
{/let}

You can see I try also to print out $temp_ts but it's only = "-1"...

Someone can copy/paste here his own .tpl ?

Thanks.

Laurent

Bjarte Lunde

Thursday 13 January 2005 7:06:10 am

Hi Laurent...

I'm working with adapting this template myself.
I want the week to start on monday.

Here is the code i'm using to show the contents of an event:

{let counter=0 
temp_ts=makedate( $view_parameters.month, $view_parameters.day, $view_parameters.year)
events=fetch( 'content', 'list', hash( 'parent_node_id', 880, 
'attribute_filter',array( 'and',array( 'event/date_from', '<=', $temp_ts),array('event/date_to', '>=',$temp_ts )) ) ) }

{section loop=$:events}
{set counter=$:counter|inc}
<h2>{$:item.object.data_map.title.content|wash}</h2>
{$:item.object.data_map.body.content.output.output_text}
{/section}
{/let}

My body field is a XML Text field. You might need to modify this a bit.