Page 1 of 1

[SOLVED] Calguy colour by category

Posted: Mon Jun 11, 2012 10:06 pm
by themiliton
Hi,
I know a similar question ahs been asked previously but I am struggling. I am using the code suggested on:
http://forum.cmsmadesimple.org/viewtopi ... =7&t=58434

yet for some reason, regardless of the category I assign an event to, they are all being given the class of 1. Am i misssing something really simple?

Re: Calguy colour by category

Posted: Wed Jun 13, 2012 5:51 pm
by Dr.CSS
You need to give a more detailed explanation of what your doing and how your doing it, notice how they posted their whole template...

http://forum.cmsmadesimple.org/viewtopi ... =40&t=2661

Re: Calguy colour by category

Posted: Sun Jun 17, 2012 11:06 am
by themiliton
OK, sorry about my lack of detail.

I have different categories assigned to different events, and want to colour code by category, in a list of upcoming events.

My Calendar template for this is as follows:


{if isset($pastitems) && $pastitems == 1}
<h1>{$lang.past_events}</h1>
{else}
<div class="upcoming"></div>
<div class="header1">Upcoming Classes</div>
{/if}

{foreach from=$events key=key item=event}
<div class=classes><a href="{$event.url}"
{if isset($event.categories)}
class="{foreach from=$event.categories item=category}{$category.category_name} {/foreach}"
{/if}
>{$event.event_title}</a></div>
<div class="info">
{assign var=month_number value=$event.event_date_start|date_format:"%m"}
{assign var=end_month_number value=$event.event_date_end|date_format:"%m"}
{if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}

{$event.event_date_start|date_format:"%e"} {$month_names[$month_number]} {$event.event_date_start|date_format:"%Y %H:%M"}
{else}
{if $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
{$event.event_date_start|date_format:"%e"} {$month_names[$month_number]} {$event.event_date_start|date_format:"%Y %H:%M"} {$lang.to} {$event.event_date_end|date_format:"%H:%M"}
{else}

{$event.event_date_start|date_format:"%e"} {$month_names[$month_number]} {$event.event_date_start|date_format:"%Y %H:%M"} {$lang.to} {$event.event_date_end|date_format:"%d"} {$month_names[$end_month_number]} {$event.event_date_end|date_format:"%Y %H:%M"}
{/if}
{/if}
</div>
{/foreach}

{if $return_url != ""}
<div class="calendar-returnlink">{$return_url}</div>
{/if}


Now my knowledge isn't great but from what I read on the previous page that I linked to, I thought this should apply a class with the category name (or id number, either is good), but instead, all elements are given the class of 1.

The html being produces is as follows:


<div class="upcoming"></div>
<div class="header1">Upcoming Classes</div>

<div class=classes><a href="http://mischiefmanagedsl.com/index.php? ... eturnid=58"
class="1 "
>Class2</a></div>
<div class="info">

18 June 2012 12:00
</div>
<div class=classes><a href="http://mischiefmanagedsl.com/index.php? ... eturnid=58"
class="1 "
>Class1</a></div>
<div class="info">

20 June 2012 17:00
</div>
<div class=classes><a href="http://mischiefmanagedsl.com/index.php? ... eturnid=58"
class="1 "
>Class2</a></div>
<div class="info">

25 June 2012 12:00
</div>
<div class=classes><a href="http://mischiefmanagedsl.com/index.php? ... eturnid=58"
class="1 "
>Class1</a></div>
<div class="info">

27 June 2012 17:00
</div>
<div class=classes><a href="http://mischiefmanagedsl.com/index.php? ... eturnid=58"
class="1 "
>Class2</a></div>
<div class="info">

2 July 2012 12:00
</div>



</div>



Thanks in advance for the help, and sorry about the previous lack of detail. If you need my actual site template or anything else, please let me know!

Re: Calguy colour by category

Posted: Sun Jun 17, 2012 8:09 pm
by Dr.CSS
I spent a couple hours trying to get this to work and finally had to get calguy1000 to help, this will output the category of the event...

{assign var='tmp' value=$event.categories|@array_keys}{','|implode:$tmp}