Use a separator between CGBlog categories

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Use a separator between CGBlog categories

Post 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
Last edited by JohnnyB on Wed Apr 28, 2010 4:41 pm, edited 1 time in total.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Post Reply

Return to “Tips and Tricks”