[SOLVED] Calguy colour by category

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
themiliton
New Member
New Member
Posts: 4
Joined: Tue Sep 06, 2011 10:01 pm

[SOLVED] Calguy colour by category

Post 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?
Last edited by themiliton on Mon Jun 18, 2012 4:22 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Calguy colour by category

Post 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
themiliton
New Member
New Member
Posts: 4
Joined: Tue Sep 06, 2011 10:01 pm

Re: Calguy colour by category

Post 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!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Calguy colour by category

Post 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}
Post Reply

Return to “Modules/Add-Ons”