Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2006-04-09 20:08:12
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Modify list of Recent article depending on chosen category
No way! It’s more convincing in duplicate ;)
Offline
Re: Modify list of Recent article depending on chosen category
Rofl :))))
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#15 2006-04-09 20:24:41
- KB
- Member
- Registered: 2006-03-13
- Posts: 21
Re: Modify list of Recent article depending on chosen category
So I changed the following:
1. in content > organize the category name is now books, shortened from books-and-movies
2. the previously posted code became:
<code>
<!— right —>
<div id=“sidebar-2”>
<p><b>Categories</b><txp:category_list break=“br” wraptag=“br” /></p>
<p><b>Latest</b>
<!— experimental —>
…
<txp:if_category name=“books”>
<txp:recent_articles label=”“ category=“books” limit=“30” break=“br” wraptag=“p” />
<txp:else />
<txp:recent_articles label=”“ limit=“30” break=“br” wraptag=“p” />
</txp:if_category>
…
<!— end experimental —>
<p>
<txp:recent_articles label=”“ limit=“30” break=“br” wraptag=“br”/></p>
</code>
AND IT DID WORK!
Then I got emboldened, cahnged all category names to a single word, not capitalized, and the code became:
<code>
<!— experimental —>
…
<txp:if_category name=“books”>
<txp:recent_articles label=”“ category=“books” limit=“30” break=“br” wraptag=“p” />
<txp:else />
<txp:if_category name=“culture”> <txp:recent_articles label=”“ category=“culture” limit=“30” break=“br” wraptag=“p” /> <txp:else />
<txp:if_category name=“economics”> <txp:recent_articles label=”“ category=“economics” limit=“30” break=“br” wraptag=“p” /> <txp:else />
<txp:if_category name=“eu”> <txp:recent_articles label=”“ category=“eu” limit=“30” break=“br” wraptag=“p” /> <txp:else />
<txp:if_category name=“persfin”> <txp:recent_articles label=”“ category=“persfin” limit=“30” break=“br” wraptag=“p” /> <txp:else />
<txp:recent_articles label=”“ limit=“30” break=“br” wraptag=“p” />
</txp:if_category>
</txp:if_category>
</txp:if_category>
</txp:if_category>
</txp:if_category>
…
<!— end experimental —>
</code>
Now, the 1st category still works, but none othe subsequent ones do.
Offline
#16 2006-04-09 20:31:26
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Modify list of Recent article depending on chosen category
You can’t nest the txp:if_category tags. So what you need is something like this:
<code>
<txp:if_category name=”“>
<txp:else />
<txp:recent_articles label=”“ limit=“30” break=“br” wraptag=“p” />
</txp:if_category></code>
(this is for the home page)
<code>
<txp:if_category name=“books”>
<txp:recent_articles label=”“ category=“books” limit=“30” break=“br” wraptag=“p” />
</txp:if_category>
<txp:if_category name=“culture”>
<txp:recent_articles label=”“ category=“culture” limit=“30” break=“br” wraptag=“p” />
</txp:if_category>
</code>etcetera… (for the category pages)
Glad you got it working :)
Offline
Re: Modify list of Recent article depending on chosen category
You can’t nest the same tag within itself. You would need to separate each category as a separate block so:-
<code>
<txp:if_category name=“books”>
<txp:recent_articles label=”“ category=“books” limit=“30” break=“br” wraptag=“p” />
</txp:if_category></code>
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Modify list of Recent article depending on chosen category
Oh I give up. I’m going to watch a DVD! :)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#19 2006-04-09 20:36:19
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Modify list of Recent article depending on chosen category
You’re not doing this on purpose are you ;)
Offline
Re: Modify list of Recent article depending on chosen category
No way, but I got one in on the plug-in forum so I’m happy. :)
“psi”? Where did that one come from?
Last edited by thebombsite (2006-04-09 20:39:47)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#21 2006-04-09 20:43:10
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Modify list of Recent article depending on chosen category
thebombsite wrote:
“psi”? Where did that one come from?
That was your 1600th post, you’ll be an omega before you know it if we go on like this ;)
Offline
#22 2006-04-09 20:46:44
- KB
- Member
- Registered: 2006-03-13
- Posts: 21
Re: Modify list of Recent article depending on chosen category
Thank you all — I redid the code as a linear sequence of ‘if’ conditions and it does work beautifully now. One has to pay attention that the home page should be
<code><txp:if_category name=”“>
<txp:else />
<txp:recent_articles label=”“ limit=“30” break=“br” wraptag=“p”/>
</txp:if_category></code>
and not
<code><txp:if_category name=”“>
<txp:recent_articles label=”“ limit=“30” break=“br” wraptag=“p” />
<txp:else />
</txp:if_category>
</code>
This latter form will not work.
I have removed the original code and the markers. Thank you all, and I hope this will help smby in the future — I would think this is a common question.
Offline
#23 2006-04-09 21:21:31
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Modify list of Recent article depending on chosen category
KB wrote:
This latter form will not work.
Nope, it will do exactly the opposite ;)
I would think this is a common question.
It is ;) Unfortunately the database was cleaned up a short while ago, so lots of posts aren’t there anymore.
Offline