Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-08-15 21:20:40

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Include subcategories on category page?

My page structure is something like:

-Category 1
—Article1
—Subcategory1
—-Article 2
—-Article 3

My main navigation points to category 1, but in the article listing on that page, i get only article1. I would like to get all articles for category 1, even if their category is set to a child of category1.
is this at all possible? or do I need to set 2 categories (category1 & Subcategory1) on each article?
oh, the tag I’m using is a simple

<txp:article limit=“10” form=“font” listform=“article_listing”/>


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#2 2010-08-16 07:22:22

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: Include subcategories on category page?

[Just a short comment (off to work)]

My page structure is something like:

Categories are not meant to define TXP structures.
It’s doable but not recommended.

Pls. check Textpattern_Semantic_Model

Fastest & most flexible solution: Use keywords. Tip: tru_tags.


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#3 2010-08-16 08:01:30

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: Include subcategories on category page?

Hm, then I’m stuck in a position where it’s basically impossible to create a hierrchical structure and navigation. Neither sections nor categories provide a way to do this.
I think I’m gonna try adi_menu, see if the fake section hierarchy works.

Sigh, some days I’m really frustrated with txp’s limitations.

PS- merzi, sorry, don’t mean for the frustration to come out on you, thanks for the reply.


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#4 2010-08-17 04:22:49

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Include subcategories on category page?

kemie wrote:

I think I’m gonna try adi_menu, see if the fake section hierarchy works.

I don’t think adi_menu will do it for you either … but I’ve sent you something that might help.

Offline

#5 2010-08-17 17:13:30

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: Include subcategories on category page?

For future reference, I solved it by using chh_article_custom with the attribute children=“y”

the default tag should have this attribute! :)


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#6 2010-08-17 22:20:57

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

Re: Include subcategories on category page?

Hi Kemie, wouldn’t this TXP Tip do what you want?

Offline

#7 2010-08-18 04:02:10

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Include subcategories on category page?

kemie wrote:

For future reference, I solved it by using chh_article_custom with the attribute children=“y”

And for the record. This was a non-plugin suggestion:

<!-- get list of parent & child categories -->
<txp:variable name="category_list"><txp:category_list parent='<txp:category />'><txp:category /></txp:category_list></txp:variable>

<!-- turn it into a comma separated list -->
<txp:php>
	$GLOBALS['variable']['category_list'] = str_replace("<br />", ",", $GLOBALS['variable']['category_list']);
</txp:php>

<!-- list articles for given categories -->
<txp:article_custom category='<txp:variable name="category_list" />'>
	<h2><txp:title /></h2>
</txp:article_custom>

It should list all articles for the current category plus its children.

Offline

#8 2010-08-18 05:32:10

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Include subcategories on category page?

gomedia wrote:

<!-- turn it into a comma separated list -->
<txp:php>
	$GLOBALS['variable']['category_list'] = str_replace("<br />", ",", $GLOBALS['variable']['category_list']);
</txp:php>

Category_list has break and wraptag attributes. break="," does the same.

Offline

#9 2010-08-18 05:50:32

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Include subcategories on category page?

Gocom wrote:

Category_list has break and wraptag attributes. break="," does the same.

Excellent – I nearly tried that but then I misread the help! Thanks.

Offline

#10 2010-08-18 07:57:42

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: Include subcategories on category page?

kemie wrote:

Sigh, some days I’m really frustrated with txp’s limitations.

All CMSs have their limitations that can usually be overcome by using plugins/modules/bespoke code. If you’re finding the limitations too great for a particular project then TXP is possibly not the right solution. That said, the more powerful and flexible a CMS is then usually the learning curve for doing things is greater making its own limitations even harder to overcome. It comes down to which is more important/relevant for what you’re working on.

Offline

#11 2010-08-18 09:05:57

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: Include subcategories on category page?

Els wrote:

Hi Kemie, wouldn’t this TXP Tip do what you want?

That comes very close to what I want. Ideally, I’d be able to show just a few of the articles in each category, and then pagination, but maybe I can make it work with just a link to the section. Thanks, els.

monkeyninja: my frustration comes from the fact that things that I think should be fairly straightforward to do with txp (for example, have a list of articles from a particular category that are paginated) aren’t and require plugins or code that goes beyond my abilities. If I didn’t have the support of this comunity, that shares code, plugins and knowledge, I’d probably just make do and get it 95% close to what I want. Thankfully, I can get to something like 98 with a bit of effort :)


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#12 2010-08-19 04:24:58

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Include subcategories on category page?

And to make the record complete, here’s the new and Gocom-improved snippet:

<txp:variable name="category_list"><txp:category_list parent='<txp:category />' break=","><txp:category /></txp:category_list></txp:variable>

<txp:article_custom category='<txp:variable name="category_list" />'>
	<h2><txp:title /></h2>
</txp:article_custom>

Offline

Board footer

Powered by FluxBB