Page 1 of 1

Calendar 0.7.8: How to set class=$day.class within calendar template?

Posted: Thu Jun 28, 2007 7:29 pm
by Michael AC
Hi all,

within the calendar template you can find this code:

Code: Select all


<td{if isset($day.class)} class="{$day.class}"{/if}>
{if isset($day.events.0)}<a href="{$day.url}">{$key}</a>
{if $summaries == true}
{* <ul>
{foreach from=$day.events item=event}
<li><a href="{$event.url}">{$event.event_title}</a></li>
{/foreach}
</ul>*}
{/if}
{else}{$key}{/if}
</td>

I don't know, where to set the $day.class... all table cells are without a class tag now, even on days with events  :(

Does someone know where to check the day class?

Thanks in advance
Michael

Re: Calendar 0.7.8: How to set class=$day.class within calendar template?

Posted: Fri Jul 06, 2007 7:32 pm
by Michael AC
Hi all,

solved by myself...

To fill the table cell that has one or more events with a different color you have to go into the calendar template.

Below is a part of the standard template provided with the calendar module:

Code: Select all

[...]
<tr>
{/if}
<td{if isset($day.class)} class="{$day.class}"{/if}>
{if isset($day.events.0)}<a href="{$day.url}">{$key}</a>
{if $summaries == true}
{* <ul>
{foreach from=$day.events item=event}
<li><a href="{$event.url}">{$event.event_title}</a></li>
{/foreach}
</ul>*}
{/if}
{else}{$key}{/if}
</td>
{math assign=weekday equation="x + 1" x=$weekday}
{/foreach}

{* remaining empty days *}
{if $weekday != 7}
<td colspan="{math equation="7-x" x=$weekday}"> </td>
{/if}


</tr>
</tbody></table>

{/strip}



So, all we need is a specific class that tells us to use a different style. I only inserted this into the code (line 4 of the code snippet above):

Code: Select all


<td{if isset($day.class)} class="{$day.class}"{/if} {if isset($day.events.0)} class="event"{/if}>

Now you can change the table cell style within the css by using i.e.

Code: Select all

td.event { background-color:blue;}
Kind regards
Michael