Alternating display dependent on news category [solved - nearly]

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
howey
Forum Members
Forum Members
Posts: 158
Joined: Fri Sep 14, 2007 1:05 pm

Alternating display dependent on news category [solved - nearly]

Post 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.
Last edited by howey on Wed Jan 14, 2009 9:38 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Alternating display dependent on news category

Post by Dr.CSS »

Searching forum for alternate colors should do it...
howey
Forum Members
Forum Members
Posts: 158
Joined: Fri Sep 14, 2007 1:05 pm

Re: Alternating display dependent on news category

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

Return to “Layout and Design (CSS & HTML)”