Page 1 of 1

Use a separator between CGBlog categories

Posted: Wed Apr 28, 2010 4:40 pm
by JohnnyB
To separate the categories shown in CGBlog summary and detail templates, use a {section} instead of a {foreach} statement:
This will separate each category with a pipe | except the last category:

Code: Select all

{if $entry->categories}
<p class="categories">
{strip}Categories: 
{section loop=$entry->categories name='category'}
{$entry->categories[category].name} 
{if !$smarty.section.category.last}| {/if}
{/section}
{/strip}
</p>
{/if}
Output

Categories: category1 | category2 | category3 | category4