Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-09-07 10:36:56
- userAnterface
- Member
- Registered: 2007-09-07
- Posts: 16
How do I make a list of categories in the side panel?
Clicking on a category should load only articles for that category in the main page.
Offline
Re: How do I make a list of categories in the side panel?
<txp:category_list /> combined with a <txp:article /> tag should do the trick.
Offline
#3 2007-09-07 11:09:46
- userAnterface
- Member
- Registered: 2007-09-07
- Posts: 16
Re: How do I make a list of categories in the side panel?
Thanks a lot, Ruud.
Offline
#4 2007-09-07 11:37:34
- userAnterface
- Member
- Registered: 2007-09-07
- Posts: 16
Re: How do I make a list of categories in the side panel?
Any idea how I could get the list into an array so I could create a UL and add classes to them?
Offline
Re: How do I make a list of categories in the side panel?
Always check the textbook :-)
txp:category_list can take the attributes break, wraptag and class.
TXP Builders – finely-crafted code, design and txp
Offline
#6 2007-09-07 11:46:39
- userAnterface
- Member
- Registered: 2007-09-07
- Posts: 16
Re: How do I make a list of categories in the side panel?
Thanks lamda :D I was on TextBook for sometime but it’s presentation is kinda disorganized and confusing for a newb.
Offline
#7 2007-09-07 13:14:04
- userAnterface
- Member
- Registered: 2007-09-07
- Posts: 16
Re: How do I make a list of categories in the side panel?
I have managed to do
<txp:category_list break=“li” wraptag=“ul” />
How do I do something like
<txp:category_list break=“li” wraptag=“ul” if(category==‘unix’) { class=“emp” } else { class=“nem” } />?
or is there something like <txp:category_list break=“li” wraptag=“ul” if(first_category) { class=“def” } else { class=“reg” } />?
Offline
Re: How do I make a list of categories in the side panel?
Do you want the class added to the “ul”?
If that is what you want, as the default “wraptag” is unset you can take that attribute out of the tag and then use something like:-
<ul class="<txp:if_category name="unix">emp<txp:else />nem</txp:if_category>">
<txp:category_list break="li" />
</ul>
remembering that you can use a comma-separated list for the “name” attribute if need be.
I’m not quite sure where that gets you though unless you have “child-categories” so I’ve probably mis-understood what you need. :(
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#9 2007-09-09 07:54:14
- userAnterface
- Member
- Registered: 2007-09-07
- Posts: 16
Re: How do I make a list of categories in the side panel?
Thanks a lot Stuart, it helped me understand the syntax lot more. But I am still confused how to go about doing what I wanna do.
Psedocode:
<ul>
for ($category_list) {
if ($current_category) print “<li class=“active”>$category</li>”
else print “<li class=“inactive”>$category</li>”
}
</ul>
I would like to apply a separate class to the li which holds the currently active category
While we are at it, how do I get $current_category?
Last edited by userAnterface (2007-09-09 08:12:03)
Offline
Re: How do I make a list of categories in the side panel?
If you look here you will see that the <txp:category_list />
tag has an attribute for “active_class”. Does that do it for you?
You might want to bookmark TextBook for future reference. It is an excellent resource, particularly for tags.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#11 2007-09-12 13:18:32
- userAnterface
- Member
- Registered: 2007-09-07
- Posts: 16
Re: How do I make a list of categories in the side panel?
Thanks a lot Stuart, that indeed did it for. I do often refer the Textbook but sometimes things aren’t as clear cos all these syntax are pretty new to me. The attributes list would be better if they were listed according to some order or atleast in an alphabetical order.
Also I was wondering if I could attach an id to the wraptag and the break tag in a random manner.
A few queries:
i. Why is it not called breaktag, if wraptag?
ii. Why apply the class to the object contained by the breaktag and not the breaktag?
<ul class=“my_ul”>
<li><a href=”“></a></li>
<li><a class=“ac“href=”“></a></li>
<li><a href=”“></a></li>
</ul>
I would like to specify a different style for the active_LI, the current system makes tough to refer to it. Is it even possible? I am still working on it.
Offline