Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
list articles in current category, but another another section
in a /section1/?c=category list page, I want to generate a list of links pointing to articles which have the same category, but which live in section2.
seems like it should be simple, but I can’t work it out!
Offline
Re: list articles in current category, but another another section
Are you using <code><txp:article /></code>?
If so, that tag is context-sensitive, and thus can’t point to articles in other sections. Try <a href=“http://textpattern.net/wiki/index.php?title=Txp:article_custom_/” title=“Txp:article custom /”>txp:article_custom /</a> instead.
Offline
Re: list articles in current category, but another another section
thanks Elenita, I can get that far, but how do I make sure it is restricted by category too?
Offline
Re: list articles in current category, but another another section
The <code>category</code> attribute doesn’t work for you?
Offline
Re: list articles in current category, but another another section
well, I can’t hard-code the category attribute because it needs to be relevent to the currently viewed one.
if I try to nest the <txp:category /> tag into the article_custom tag it breaks
eg.
<code><txp:article_custom section=“2” category=”<txp:category />” /></code>
Offline
Re: list articles in current category, but another another section
Ah. I should have realized that. Sorry, I’m <a href=“http://wordpattern.org”>distracted</a> today.
Do you have lots of categories? A workaround I can think of is the use of conditionals (<code><txp:if_category></code> specifically), but I’m sure that someone will come up with a more elegant solution before too long.
Offline
Re: list articles in current category, but another another section
Elenita wrote:
Ah. I should have realized that. Sorry, I’m <a href=“http://wordpattern.org”>distracted</a> today.
thats nuts!
Elenita wrote:
Do you have lots of categories? A workaround I can think of is the use of conditionals (<code><txp:if_category></code> specifically), but I’m sure that someone will come up with a more elegant solution before too long.
from Textbook:
The if_category tag is a Conditional Tag, and therefore a Container Tag, as all conditional tags are container tags. Textpattern will replace this tag with the result of the contained statment when the name attribute matches a category search value / or (?c=Category, an article list by category).
so in my page template, for a url of <code>section1/?c=categoryname</code> this code
<code><txp:if_category><txp:article_custom section=“2” /></txp:if_category></code>
should return a list of articles from section 2 with a category value of ‘categoryname’
except it doesn’t :(
it just lists all articles from section 2, regardless of category
did I use it correctly?
Offline
Re: list articles in current category, but another another section
Elenita wrote:
Sorry, I’m <a href=“http://wordpattern.org”>distracted</a> today.
got me there :o)
Offline
Re: list articles in current category, but another another section
That didn’t even occur to me, honestly. I was thinking of something like:
<code>
<txp:if_category name=“books”>
<txp:article_custom category=“books” section=“other” />
</txp:if_category>
<txp:if_category name=“food”>
<txp:article_custom category=“food” section=“other” />
</txp:if_category>
</code>
etc…
Like I said, it’s not very elegant.
Last edited by Elenita (2006-04-01 16:20:06)
Offline
Re: list articles in current category, but another another section
ok, thanks for the suggestion anyway, but I need to do it without hard-coding the category names as the list of categories may change after I hand the site over.
anyone else got any ideas?
Offline
#11 2006-04-01 17:02:12
- rsilletti
- Moderator
- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: list articles in current category, but another another section
<code><txp:php> $atts[‘category’] = parse(‘<txp:c />’);</txp:php></code>
Should set your category attribute to the current category if you have searched by category and set the variable “c”. If <code> <txp:c /></code> doesn’t return what I expect you can use GET.
Set $atts[ ‘category’ ] before you call article_custom. You can set the rest of the attributes the same way and call article_custom from between the php tags with
<code> echo article_custom($atts); </code>
Offline
#12 2006-04-01 17:03:34
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: list articles in current category, but another another section
Try chh_article_custom, you can use category=”?” with that, meaning the current category.
Offline