Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Change article output depending on category name?
I’ve searched the forums and found a couple of solutions I thought might work but alas I couldn’t pull it off. On the front page of my site I have excerpted posts of the latest four entries. Each entry is prefaced by a thumbnail of the post (you can see what I’m talking about here: The Human Museum – What i want to do is keep that styling UNLESS it is a post in my “photoblog” category. If it’s a photoblog post I want to display it differently without the thumbnail and just the straight up excerpt. I just need to know what tags I’d need for the form to check which category the post is from and output the two different styles depending on which category the post belongs. Any ideas?
Here’s the code I have…
<code><div id=“post”>
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<h2>
<div class=“rssthumb”><txp:permlink><txp:hak_article_thumb/></txp:permlink></div>
</h2>
<p><txp:kgr_safe_excerpt words=“100” linktext=”<em>Keep Reading</em>” /></p></div>
</div><div style=“margin:50px;”></code>
Here’s what I want to happen…
<code><div id=“post”>
<txp:if_category name=“photoblog”>
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<p><txp:kgr_safe_excerpt words=“100” linktext=”<em>Keep Reading</em>” /></p>
<txp:else />
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<h2>
<div class=“rssthumb”><txp:permlink><txp:hak_article_thumb/></txp:permlink></div>
</h2>
<p><txp:kgr_safe_excerpt words=“100” linktext=”<em>Keep Reading</em>” /></p></div>
</txp:if_category>
<div style=“margin:50px;”></div></code>
What am I doing wrong?
Last edited by The Human Museum (2005-12-14 06:34:03)
“I was born to hustle roses down the avenues of the dead.” – Charles Bukowski
The Human Museum
Offline
#2 2005-12-14 06:53:29
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Change article output depending on category name?
Alex
Offline
Re: Change article output depending on category name?
Ok, so if I change the code to:
<code><div id=“post”>
<txp:if_article_category name=“photoblog”>
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<p><txp:kgr_safe_excerpt words=“100” linktext=”<em>Keep Reading</em>” /></p>
<txp:else />
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<h2>
<div class=“rssthumb”><txp:permlink><txp:hak_article_thumb/></txp:permlink></div>
</h2>
<p><txp:kgr_safe_excerpt words=“100” linktext=”<em>Keep Reading</em>” /></p>
</txp:if_article_category>
</div>
<div style=“margin:50px;”></div></code>
I just get a blank page without any articles being output. Is that I was supposed to change after reading the FAQ? I’m not slow, really, but I’m not sure how to move forward here.
Last edited by The Human Museum (2005-12-14 07:11:34)
“I was born to hustle roses down the avenues of the dead.” – Charles Bukowski
The Human Museum
Offline
Re: Change article output depending on category name?
For now I’m overiding the article form from the posting interface. It’s a work around though I’d still really like to know what I’m doing wrong.
“I was born to hustle roses down the avenues of the dead.” – Charles Bukowski
The Human Museum
Offline
#5 2005-12-14 09:28:12
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Change article output depending on category name?
The last one you posted should work. Did you double-check your category’s name?
Offline
Re: Change article output depending on category name?
Yes, still a no go.
“I was born to hustle roses down the avenues of the dead.” – Charles Bukowski
The Human Museum
Offline
#7 2005-12-14 22:19:00
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Change article output depending on category name?
I just get a blank page without any articles being output.
Alex
Offline
Re: Change article output depending on category name?
Alright, turning on testing I get:
<code>tag_error <txp:else /> -> Textpattern Warning: unknown_tag</code>
To be more clear it’n not that my page is completely blank – the site renders fine, simply there are no posts where there is supposed to be posts.
And I’m using 4.0.2
Last edited by The Human Museum (2005-12-15 05:03:20)
“I was born to hustle roses down the avenues of the dead.” – Charles Bukowski
The Human Museum
Offline
#9 2005-12-15 06:14:57
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Change article output depending on category name?
Try taking the <em>..</em>
tags out of the safe_excerpt tag atts.
Alex
Offline
Re: Change article output depending on category name?
That did it, thanks zem
“I was born to hustle roses down the avenues of the dead.” – Charles Bukowski
The Human Museum
Offline