Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-07-31 19:02:19
- saturnflyer
- Member
- Registered: 2006-01-22
- Posts: 40
display article category name outside of article form
I’d like to set the class attribute on my body to the category of the current article and I can’t figure out how to do it. Currently I’m using <txp:section /> to add the section name as the class name, but I’d like to add <txp:category />
Is this possible? (or anything like it, such as getting an article_custom field to display in the body class?)
Offline
#2 2006-07-31 19:37:05
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: display article category name outside of article form
You’d need a second <txp:article /> tag. Create an article form (e.g. ‘category_form’) with just <txp:category1 /> in it, and use
<code>
<txp:if_individual_article>
<body class=”<txp:article form=“category_form” />”>
</txp:if_individual_article>
</code>
Mind that you’ll have to turn ‘automatically append comments to articles’ off, or comments will show in strange places… (Comment display confusion)
But it certainly can be done, I’m using article tags this way to have different meta description and keywords based on the individual article.
There is probably also a way do do this with php on your page, but someone else will have to tell you how ;)
Offline