Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-09-19 16:04:44

Xell
New Member
From: Canada
Registered: 2007-09-19
Posts: 5

Article Specific Styling based on Catagory

Hi, hoping someone can answer this for me.

My site is setup like this, I have one main page that contains several different articles on various topics. I would like to color code this article titles based on category (News-Red, Tutorials-Green, ect.)

I know I have to alter the article form to put something like this…

<txp:if_article_category name=“News-Updates” number=“1”>
<div id=“artNewsDiv”><txp:article form=“default” /></div>
<txp:else />

but I’m not sure what the exact code should be. So far everything I’ve done hasn’t worked. My articles still show up without a id wrapper around them.

Any help would be great.

Offline

#2 2007-09-19 16:25:25

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Article Specific Styling based on Catagory

Page template:

<txp:article form="default" />

Default article form :

<txp:if_article_category name=“News-Updates” number=“1”>
<div id=“artNewsDiv”>
</txp:if_article_category>

<txp:if_article_category name=“another-category” number=“1”>
<div id=“anothercategorydiv”>
</txp:if_article_category>

<h2><txp:title></h2>
<txp:body />
...
</div> <!-- this div closes any "category div" open above by conditionals tags -->

I hope that helps.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2007-09-19 16:28:29

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Article Specific Styling based on Catagory

Other option, without using conditionals.
In your article form:

<div class="<txp:category1 />"> 
<h3><txp:title /></h3>
...etc...
</div>

And then, you create different CSS rules based on your categories names.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2007-09-19 19:24:04

Xell
New Member
From: Canada
Registered: 2007-09-19
Posts: 5

Re: Article Specific Styling based on Catagory

maniqui wrote:

Other option, without using conditionals.
In your article form:

<div class="<txp:category1 />"> 
<h3><txp:title /></h3>
...etc...
</div>

And then, you create different CSS rules based on your categories names.

I really like this idea. Thanks alot to the both of you.

Offline

#5 2007-09-19 19:38:52

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Article Specific Styling based on Catagory

Xell wrote:

I really like this idea. Thanks alot to the both of you.

We are the same!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2007-09-19 20:07:13

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Article Specific Styling based on Catagory

Well that’s just your opinion maniqui. I wonder what the other one thinks about it. ;)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

Board footer

Powered by FluxBB