Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-05-06 20:55:53
- Insignia
- Member
- Registered: 2006-05-05
- Posts: 13
Category issues
Hello! I’m a Textpattern n00b.
I’ve looked through the FAQ, documentation and forums, and I can’t seem to find what I want. Feel free to point and laugh if there’s already an answer somewhere. :)
Is there a tag/plugin/hack (in order of preference) to check whether an article is categorised? I know how to check for a specific, named category, but I want to show a different piece of code depending on whether the article has a category (any one at all) or not (i.e. both category fields are empty).
As a last resort, can I somehow set a default category, so that everything is categorised even if I forget to pick one?
Offline
#2 2006-05-06 21:44:12
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Category issues
<txp:if_article_category name="">
here the code for no category
<txp:else />
here the code you want if a (any) category is set
</txp:if_article_category>
(This goes in the article form.)
Edit: forget this, wrong answer :(
Last edited by els (2006-05-06 22:17:04)
Offline
#3 2006-05-06 22:00:23
- Insignia
- Member
- Registered: 2006-05-05
- Posts: 13
Re: Category issues
Well, that makes perfect sense in theory, but it doesn’t seem to work. Here’s what I’m trying to do: If an article has a category, there’s a link to said category next to the article. If it has no category, there’s a link to the section instead. I’m using this code:
<code><txp:if_article_category>
<txp:category1 link=“1” title=“1” />
<txp:else />
<txp:section link=“1” title=“1” />
</txp:if_article_category></code>
But it only links to the section even if the article has a category. I’m sure I’m missing something obvious.
Offline
#4 2006-05-06 22:03:42
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Category issues
Sorry, I just edited my post above (I turned things around…)
Offline
#5 2006-05-06 22:05:42
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Category issues
And no, that doesn’t work either :( I’m sure I did a thing like this a while ago… Let me think about it some more.
Offline
#6 2006-05-06 22:09:33
- Insignia
- Member
- Registered: 2006-05-05
- Posts: 13
Re: Category issues
Thanks anyway. :) If I can’t get this to work, I’ll just have to think of an alternative. That I know how to do.
Offline
#7 2006-05-06 22:15:30
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Category issues
Sorry about that. I realize now that if_article_category doesn’t work the same way as if_category. Would chh_if_data help you?
Offline
#8 2006-05-06 22:29:17
- Insignia
- Member
- Registered: 2006-05-05
- Posts: 13
Re: Category issues
Would chh_if_data help you?
Yes! That fixed it! Thanks a lot. :D
Offline
Pages: 1