Page 3 of 3

Re: how to show cgcalendar categories??

Posted: Tue Mar 13, 2012 10:55 am
by Peciura
Try

Code: Select all

{foreach from=$events key=key item=event}
<td valign="top">
	{if !empty($event.categories)}
		{foreach from=$event.categories item='cat_name'}
			{$cat_name}<br/>
		{/foreach}
	{/if}
</td>
{/foreach}

Re: how to show cgcalendar categories??

Posted: Thu Mar 22, 2012 5:57 pm
by JohnnyB
This works for me in an Upcoming Events template (display='upcominglist') inside the $events foreach statement:

Code: Select all

{foreach from=$event.categories item='value' key=key}
{$key}<br/>
{/foreach}
the array printed with {$event.categories|print_r} shows something like:
Array
(
[Category Name A] => 1
[Category Name B] => 1
)
the foreach $key prints the category name and the $value prints '1' because *I think* that the 1 is like a flag set when the category is true for an event.

Re: how to show cgcalendar categories??

Posted: Wed Aug 22, 2012 7:21 am
by Franck
I have a problem showing categories on several templates.

I used this:

Code: Select all

{* event categories *}
{if !empty($event.categories)}
  {assign var='event_categories' value=$event.categories|@array_keys}
  {', '|implode:$event_categories}
{/if}
{* end event categories *}
It works perfectly on upcominglist template, but neither pastlist nor detail templates displays the categories.

I also tried several other solutions provided in this subject, no success. Any reason, tip, idea?

Thank you.

Re: how to show cgcalendar categories??

Posted: Wed Aug 29, 2012 8:33 am
by Franck
Ok I figured it out. Actually, I was using the "pastlist" display that has no template (why?), so I switched to "list" display, and it's working as expected.