Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-08-14 16:08:26

MattH
Member
From: Ann Arbor, MI
Registered: 2004-10-17
Posts: 30

Have category pages show children?

Is there a way to have category pages also show children of the category?

For example, I have a category called “Transportation” with subcategories “Bus” and “Train”. If I categorize a page “Bus”, it doesn’t show up under the Transportation category, but I’d like it to.

Offline

#2 2008-08-14 16:17:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,280
Website GitHub

Re: Have category pages show children?

MattH wrote:

Is there a way to have category pages also show children of the category?

I’m not sure if it’s what you’re looking for, but does <txp:category_list /> help at all? Or if you need the ‘reverse’ (get parents from a child category), try the smd_parent plugin.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2008-08-14 16:25:59

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Have category pages show children?

I think he’s looking for an article list on a category page that shows not only articles in that category but also articles in child categories. In 4.0.7, you may be able to do that by using article_custom list and fill the ‘category’ attribute value with the results of a plugin tag that can list all child categories as a comma-separated list.

Requirements:
  • current category: <txp:category />
  • plugin that can return child categories as a comma separated list: <txp:smd_parent break="," category='<txp:category />' /> (this is an example, I don’t know if this give the desired result)
  • use that in article_custom: <txp:article_custom category='<txp:category />,<txp:smd_parent break="," category=''<txp:category />'' />' />

Hmm… this could very well be the first example I’ve ever seen where two levels of attribute value parsing are actually shown in a useful way ;)

Or, if you can’t wait, you could write a plugin that does something similar, perhaps even in a single query (which would no doubt involve at least a join and perhaps a sub select).

Last edited by ruud (2008-08-14 16:28:37)

Offline

#4 2009-04-17 17:57:30

jordi
Member
From: Barcelona
Registered: 2005-09-14
Posts: 94
Website

Re: Have category pages show children?

I’m trying to do just that. Is the above answer still the best solution available in 4.0.8?

Offline

#5 2009-04-17 19:34:41

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

Re: Have category pages show children?

With a little bit more code you can even do it without plugin :)

<txp:article_custom category='<txp:category_list parent=''<txp:category />'' break=""><txp:category /><txp:if_last_category><txp:else />,</txp:if_last_category></txp:category_list>' />

Offline

#6 2009-04-20 16:50:52

jordi
Member
From: Barcelona
Registered: 2005-09-14
Posts: 94
Website

Re: Have category pages show children?

ok, thanks, I will try this.

Offline

Board footer

Powered by FluxBB