Page 1 of 1

Alternating display dependent on news category [solved - nearly]

Posted: Tue Jan 13, 2009 10:16 pm
by howey
Hi

Can anyone point me in the right direction. I am trying to write a news summary template that will display the news summaries with different colour backgrounds dependent on their category.

I though that I could check the category value and use "if" "elseif" staements dependent on the category name. I don't seem to be able to get the category name/variable to check though.

Code: Select all

<!-- Start Notice Display Template -->

{foreach from=$items item=entry}

{if $category_label=="purple_notice"}

<div class="purplenotice">

<h3>{$entry->title}</h3>

{if $entry->summary}
<p>{eval var=$entry->summary}</p>
{/if}

</div>

{/if}

{/foreach}

<!-- End Notice Display Template -->
Something like the above then adding elseif statements. I hope I have explained myself OK.

Any advice help gratefully received.

Re: Alternating display dependent on news category

Posted: Tue Jan 13, 2009 10:23 pm
by Dr.CSS
Searching forum for alternate colors should do it...

Re: Alternating display dependent on news category

Posted: Wed Jan 14, 2009 9:37 am
by howey
Hi

Found the cycle function mentioned  ;D – I think this will work better than what I was trying to do in that it assigns alternating styles to news items. A bit simpler than choosing styles based on the category.

I would still find it useful to know how to call the news category though – I'll dig around and see if I can solve it.