Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-01-16 08:16:58
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Tabs that display articles in category x
Hi guys, I’m trying to create a simple sub-nav that will display articles associated with just a particular category within the current section. In my case ‘male’ or ‘female’.
So when the female tab is clicked the main page just display articles in ‘female’ category.
Not sure how to integrate this into my main page. Markup is:
<ul class=“tabs”>
<li><a href=”#”>Male</a></li>
<li><a href=”#”>Female</a></li>
</ul>
Any help much appreciated !
Offline
Re: Tabs that display articles in category x
Try this: <txp:category_list break="li" class="tabs" this_section="1" type="article" wraptag="ul" />
Or with predefined categories: <txp:category_list break="li" categories="male, female" class="tabs" this_section="1" type="article" wraptag="ul" />
Digital nomad, sailing the world on a sailboat: 32fthome.com
Offline
#3 2009-01-16 09:14:22
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Re: Tabs that display articles in category x
Yeah thats great! Thanks trenc:
<txp:category_list active_class=“active” break=“li” categories=“male,female” class=“tabs” sort=“title asc” this_section=“1” type=“article” wraptag=“ul” />
And to display the results in a particular way I just change the <txp:if_category> tags in the main page.
Offline
#4 2009-02-03 18:28:03
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Re: Tabs that display articles in category x
Hmm seem to have come across a bit of a problem with this form. Everytime another article is added the female, or male tab on the homepage gets duplicated!!! Can anyone tell me why this is happening?
Offline
#5 2009-02-03 21:14:43
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Tabs that display articles in category x
What is the code you are using on the home page?
Offline
#6 2009-02-03 21:28:50
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Re: Tabs that display articles in category x
Homepage:
<txp:article form=“bass_tabs” limit=“1” />
Form:
<txp:category_list active_class=“active” break=“li” categories=“male,female” class=“tabs” sort=“title asc” this_section=“1” type=“article” wraptag=“ul” />
Not sure if it was the correct way of doing it but adding a limit=“1” to the <txp:article form />in the homepage fixed it/
Last edited by mrjysta (2009-02-03 21:29:30)
Offline
#7 2009-02-03 21:54:59
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Tabs that display articles in category x
Hmm, you are not supposed to use a form like that in an article tag ;) You can either use <txp:output_form form="bass_tabs" />
or just use the category_list tag that is now inside your form directly on the page.
An article form ( like this: <txp:article form="yourform" />
) is used to display the different parts of an article, like <txp:title />
, <txp:body />
, <txp:excerpt />
, <txp:posted />
and so on.
Offline
Re: Tabs that display articles in category x
mrjysta wrote:
Not sure if it was the correct way of doing it but adding a limit=“1” to the <txp:article form />in the homepage fixed it/
Would be better to use:
<txp:output_form form="bass_tabs" />
The <txp:article />
should only be used when showing articles. Plus you don’t really want to cause extra server stress with populating article tags and adding extra queries :)
Edit. Els was faster with couple minutes, but extra information is always good :D
Last edited by Gocom (2009-02-03 22:00:26)
Offline
#9 2009-02-04 01:12:31
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Re: Tabs that display articles in category x
All fixed, + answers a lot of my other questions as to why things were not working on my homepage :-/ Thanks guys .
Offline