Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-05-26 14:17:55

leafy_loader
Member
Registered: 2008-09-25
Posts: 96

List sub category articles along with parent category articles

I’m sure this is a simple one but for the life of me I can’t work it out.

I have articles stored under various categories. Some categories have child categories with articles assigned. All I want to do is list the title and body of all articles on one page, both from parent and child categories.

At the moment all I seem to be able to do is list the parent category articles.

Offline

#2 2010-05-26 17:51:39

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,254
Website GitHub Mastodon Twitter

Re: List sub category articles along with parent category articles

All I want to do is list the title and body of all articles on one page

Are you sure? That will list virtually all site content.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2010-05-26 17:51:55

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

Re: List sub category articles along with parent category articles

<txp:article_custom category='<txp:category_list parent="yourparentcategory" break=","><txp:category /></txp:category_list>'>
   <h3><txp:title /></h3>
   <txp:body />
</txp:article_custom>

If ‘yourparentcategory’ should be the current category (if you are on a category page), do this:

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

Offline

#4 2010-09-07 16:22:52

husainhk
Member
From: Dubai, UAE
Registered: 2007-08-12
Posts: 105
Website

Re: List sub category articles along with parent category articles

Hello Els,

Can your snippet above be used to generate something like this, on a parent category landing page:

Child Category 1
List of articles (formatted using a form)
Link to all articles in this child category

Child Category 2
List of articles (formatted using a form)
Link to all articles in this child category

Child Category 3
List of articles (formatted using a form)
Link to all articles in this child category

Appreciate it!

Offline

#5 2010-09-07 18:42:40

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

Re: List sub category articles along with parent category articles

Hi Husain,

If you want to display the category titles as well, I think something like this would be better:

<txp:category_list parent='<txp:category />' exclude='<txp:category />' break="">

   <!-- Child Category -->
   <txp:category title="1" />

   <!-- List of articles (formatted using a form) -->
   <txp:article_custom category='<txp:category />' form="yourform" />

   <!-- Link to all articles in this child category -->
   <txp:article_custom category='<txp:category />'>
      <txp:permlink><txp:title /></txp:permlink>
   </txp:article_custom>

</txp:category_list>

Note that the <txp:category /> used as a value for the attributes in the category_list tag indicate the current category (i.e. the category that is in the URL of the current page); the <txp:category /> tags inside the category_list opening and closing tags indicate the current category in the list.

Hmm… reading it over I’m not so sure I made myself clear… ;)

Edit: I added break="" in the category_list tag because if you leave that attribute out it will automatically add <br />s after every list item.

Last edited by els (2010-09-07 18:46:19)

Offline

#6 2010-09-07 20:23:09

husainhk
Member
From: Dubai, UAE
Registered: 2007-08-12
Posts: 105
Website

Re: List sub category articles along with parent category articles

It sounds all clear to me Els! Will check this out and share my Ahas :)

Just one thing though, guess I wasn’t clear – the third item, “Link to all articles in this child category” is actually a “Show all articles in this category” … another landing page for that child category. So, would this work:

<txp:category title=“1” link=“1”>All articles in this category</txp“category>

Cheers,
Husain

Offline

#7 2010-09-07 20:26:42

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

Re: List sub category articles along with parent category articles

Ah, I misunderstood that ;)

Offline

Board footer

Powered by FluxBB