Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-08-17 16:00:00

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

Display Articles In Specific Category Selected From Category List

I am working on a catalog. Here is what I need to achieve:

1. I have a section of Boxes with Categories of Black, Red, White, Blue.
2. Display the list of categories (colors) as links. Maybe using category_list
3. When the user clicks on a color, black for example, only the black items/articles will be displayed.
4. When the user clicks on an item/article they will go to the individual_article

I would like to use txp native tags and stay away from plugins. I’m sure it can be done using if/else tags, but I’m not sure how to put it all together.

Any help appreciated.


Art Rogue – Fine Art Photography

Offline

#2 2007-08-17 16:22:48

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: Display Articles In Specific Category Selected From Category List

im sure something similar to the following would work

<txp:category_list categories="your categories, in the order, you want them, to appear" />
when a category is clicked it should take you through something like:
<txp:if_article_list>
	<txp:article form="a form outputting your articles/boxes"/>
</txp:if_article_list>
<txp:if_individual_article>
	<txp:article form="a form outputting that single article/box"/>
</txp:if_individual_article>

Offline

#3 2007-08-17 16:33:55

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

Re: Display Articles In Specific Category Selected From Category List

Like this:

<txp:if_section name="archive">
<txp:category_list label="Categories" labeltag="h2" wraptag="ul" break="li" class="category-list" />
<txp:if_category name="black">
<txp:article_custom limit="9999" form="archive-list" category="black" section="boxes" />
</txp:if_category>
<txp:if_category name="red">
<txp:article_custom limit="9999" form="archive-list" category="red" section="boxes" />
</txp:if_category>
<txp:if_category name="white">
<txp:article_custom limit="9999" form="archive-list" category="white" section="boxes" />
</txp:if_category>
</txp:if_section>

In archive-list something like:

<txp:permlink><txp:posted /> : <txp:title /></txp:permlink>

Or if you use it on section where articles are posted you can use <txp:article /> – it’s content and category sensitive.

Cheers!

EDIT. iblastoff was faster :D

Last edited by Gocom (2007-08-17 16:38:20)

Offline

#4 2007-08-17 16:37:28

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

Re: Display Articles In Specific Category Selected From Category List

I can’t get it to work.

I’m getting the error: Page template index does not contain a txp:article tag in…

However, my section is not using the template index, it is using a template of default. I have a seperate template called index for my front page. Is there a setting off.

Is iblastoff’s method better. The if_category method makes more sense to me.

Last edited by mattmikulla (2007-08-17 17:57:45)


Art Rogue – Fine Art Photography

Offline

#5 2007-08-17 19:52:59

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

Re: Display Articles In Specific Category Selected From Category List

How do I stop the category list from attempting to display on the front page? My layout is different on the front page.

edited

I solved the problem by assigning a section=“moulding” to my category_list tag.

<txp:category_list label="Categories" labeltag="h2" section="moulding" wraptag="ul" break="li" class="category-list" />

Last edited by mattmikulla (2007-08-17 21:26:05)


Art Rogue – Fine Art Photography

Offline

Board footer

Powered by FluxBB