Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Some guidance required in using categories and category parents please
Hi all,
I’m trying to recreate in textpattern an effect on a static site I built some time ago.
Basically, I have a bunch of articles which are categorized according to country (i.e. France, Spain, England, Belgium) and each of these categories has a parent category (i.e. Europe, Asia, North America, South Africa…) and all these categories belong to another parent category called ‘Regions’.
Some countries have only one article, some have several. (The articles themselves are simply bullet lists detailing expeditions held in each of these countries.)
What I require is a mechanism that will display a clickable list of all the ‘Regions’ categories on a page which will direct the user to a new page that lists out all the countries from that Region with their available expeditions listed underneath each country name.
Is it possible to get a list of categories that belong to a parent category, and under each of those categories display a list of articles (title and body required)
i.e.
Screen 1
Asia (parent category)
Europe (parent category)
North America (parent category)
South Africa (parent category)
and so on…
Screen 2 – Asia has been clicked, so use a conditional tag to check for /?c=asia to display articles belonging to child categories of ‘asia’
Current expeditions in Asia:
Nepal (child category)
-expedition 1 (full article)
-expedition 2 (full article)
India (child category)
-expedition 1 (full article)
China (child category)
-expedition 1 (full article)
-expedition 2 (full article)
and so on…
But for some reason unknown to me, textpattern won’t display articles in child categories of their parents (i.e. Europe, Asia, North America, South Africa…) when using /?c= in the url. Yet, using /?c= with a child category (i.e. Nepal, India, China…) does produce a list of articles related to each country.
Is this because ‘article_custom’ tags only list articles in categories that have been assigned to articles directly, not their parents?
I have managed to get the second part sort of working by using:
<pre>< txp:stw_category_tree start=“Asia” maxlevel=“1” section=“destinations” /></pre>
<pre>< h3 >Expedition highlights – < txp:category title=1 />< /h3 ></pre>
<pre>< txp:chh_article_custom form=“expedition_list” listform=“expedition_list” section=”?” category=”?” /></pre>
Which produces a list of countries belonging to Asia, and clicking each country name changes the list of related articles below it. I then added < txp:category title=1 /> to display the country name before the expedition list… but as explained I want one page that displays all articles of children belonging to a parent category (Asia for example), with each of those child categories displayed above them.
I would really apreciate any insight into how to solve this problem!
Have I hit a limitation in textpattern?
thanks in advance.
Luke
Last edited by lukepermsn (2006-07-24 16:47:04)
“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee
Offline
Re: Some guidance required in using categories and category parents please
Are you using both categories? If not, then why don’t you categorise each article twice. Category1 would assign a continent to an article, and category2 would assign a country. Now you can list articles by continent and sort them by category2 and use the if_different tag. For example:
<txp:chh_article_custom sortby="category2,Posted" form="expedition_list" />
And for the form
<code>
<txp:if_different>
<h2><txp:category2 link=1 /></h2>
</txp:if_different>
<h3><txp:permlink><txp:title /></txp:permlink></h3>
<txp:body />
</code>
Offline
Re: Some guidance required in using categories and category parents please
I do believe that was an incredibly simple solution to my problem. I salute you sir!
Easy when you know how, eh?
Thanks so much…
So, to answer the above in part, it’s not possible to list articles via a category parent? it has to be a category directly assigned to the articles?
cheers.
Luke
“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee
Offline
Re: Some guidance required in using categories and category parents please
I can’t answer that question with any authority. Anyone else know?
Offline
#5 2006-07-24 22:32:01
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Some guidance required in using categories and category parents please
…it’s not possible to list articles via a category parent? it has to be a category directly assigned to the articles?
I don’t understand the question.
Offline
#6 2006-07-24 22:40:10
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Some guidance required in using categories and category parents please
lukepermsn wrote:
So, to answer the above in part, it’s not possible to list articles via a category parent? it has to be a category directly assigned to the articles?
If you mean that category ‘X’ is assigned to article ‘Y’, and category ‘X’ has a parent category ‘Z’, and category ‘Z’ is not assigned to article ‘Y’, then article ‘Y’ won’t show up when category ‘Z’ is requested. So the answer is: that’s right, it is not possible :)
Offline
Re: Some guidance required in using categories and category parents please
yes, that’s what I mean! ok…
then ricetxp’s solution is the one for me – using both category dropdowns to independently list expeditions by Region or Country.
thanks for the help guys.
“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee
Offline
Re: Some guidance required in using categories and category parents please
@ Els:
That means assigning parent categories has no practical benefits. Yes, the hierarchy is reflected by the indenting of child categories in the admin panel, but that’s not very useful. I think that making it possible to filter / display parent categories on the front-end would be a very useful and logical improvement to TXP.
Kensington TXP powered rock
Offline
#9 2006-09-26 20:44:09
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Some guidance required in using categories and category parents please
I suppose you’re right, Jan. I myself have never come across a situation where this would be useful, but I’m using parent categories on one site where some categories should only be assigned to articles in one section, and other categories are only for articles in another section. So I created parent categories with the same names as the sections to make this visible for the end user.
Offline
Re: Some guidance required in using categories and category parents please
Yes, the ability to assign a parent category, that will include all articles or images within the parents sub categories would be an incredibly useful addition IMHO.
Equally for images – the ability to request ‘Africa’ as a parent, which will include all subcats of Africa (Tanzania, Ethiopia, Namibia etc.) would be a huge improvement, so that I could conditionally select whether I want a random image from Africa, which would include all subcats, or become specific in terms of displaying an image (or article) that is only in a particular subcat of said parent (Namibia for instance).
That would then make random image plug-ins such as ‘smd_random_banner’ incredibly useful, and also enable categories to be really used as navigation structures without the need for sub sections.
Otherwise, as said above, it appears to be a fairly useless tool to apply parents to categories, except to visually organize the display within textpattern.
L.
“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee
Offline