Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-05-15 16:36:54

saturnflyer
Member
Registered: 2006-01-22
Posts: 40

output name of category for current article

I’m trying to figure out how to output the name of the category of the current article from any page (not just a category page).

Do I need to do something special with article_category to get it to work on an article page?

Offline

#2 2006-05-15 17:32:49

ricetxp
Member
From: London, UK
Registered: 2005-05-24
Posts: 89
Website

Re: output name of category for current article

Within the article form you can use <txp:category1 title=1 /> or <txp:category2 title=1 />

Offline

#3 2006-05-15 18:21:00

saturnflyer
Member
Registered: 2006-01-22
Posts: 40

Re: output name of category for current article

after I read your response, I realized my mistake. I left out that I want to do this on a page, and not the article form.

For instance, I am able to get the section, but not the category for this code:
<code><body class=“section category”></code>

Offline

#4 2006-05-15 21:10:09

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: output name of category for current article

So you need this for an individual article page? There is a way, but you’ll have to turn ‘automatically append comments to articles’ off.
Create an article form with only this:
<code>
<txp:category1 />
</code>
Then use
<code>
<txp:if_individual_article>
<body class=”<txp:section /> <txp:article form=“nameofyourform” />”>
</txp:if_individual_article>
</code>
I’ve not tried this myself, but I don’t see a reason why it shouldn’t work. I’m using something similar in the head, for the output of custom meta data for individual articles. But if you forget to turn ‘auto-append comments’ off, comments will appear in very strange places ;)
(Edit: this also breaks comment preview, so better not use it if you have comments on.)

Last edited by els (2006-05-21 20:17:32)

Offline

Board footer

Powered by FluxBB