Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-01-31 16:39:29

Manaus
Member
From: Turin, Italy
Registered: 2010-10-22
Posts: 252
Website

Printing related articles to parent category

Hello, I need to print the related articles of the parent category, when viewing an article.

This is my category tree, with item number between brackets:

Parent (0)
  child01 (6)
  child02 (2)

So when viewing a child02 article, I need to print the child01 and child02 related articles.

Thank you very much

Offline

#2 2011-01-31 17:23:33

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Printing related articles to parent category

The general steps:

  1. get the parent category for the current article; can use smd_parent for this
  2. make a category_list based on the parent
  3. use the category list as the basis for an article_custom list

This gets more complicated if you need to allow for the article having this child category as either its category1 or its category2. I’ll assume category1 only (untested code):

<txp:article_custom category='<txp:category_list parent='<txp:smd_parent catnum="1" />' break=","><txp:category /></txp:category_list>'>
	<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>

Code is topiary

Offline

Board footer

Powered by FluxBB