Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-10-19 17:24:05

CharlesCountyArtsAlliance
New Member
Registered: 2009-10-19
Posts: 6

Defining LI class with cbs_category_list

I’d like to have a navigation bar that shows the list of categories in a section, outputted by cbs_category_list, with randomly selected alternating classes for the list items that will show a different background color on each one.

I attempted to accomplish this using cbs_category_list and gho_alternation, using the following code:

<txp:cbs_category_list parent='<txp:section/>' wraptag="ul" break="li class='<txp:gho_alternation returns="sn1,sn2,sn3,sn4 random="1" />'" />

That code did nothing, and I had a feeling that it wouldn’t. That being the case, what is the best way to achieve random alternating background colors on each LI, preferably in combination with cbs_category_list?

Offline

#2 2009-10-19 17:53:25

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Defining LI class with cbs_category_list

Try closing parentheses correctly like <txp:cbs_category_list parent='<txp:section />' wraptag="ul" break="li" class='<txp:gho_alternation returns="sn1,sn2,sn3,sn4" random="1" />' />. If this fails try again in the plugin’s own thread (gho code looks alright).

Edit: added a space in the section tag.

Last edited by uli (2009-10-19 18:03:17)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2009-10-19 18:06:09

CharlesCountyArtsAlliance
New Member
Registered: 2009-10-19
Posts: 6

Re: Defining LI class with cbs_category_list

That code works, technically, but the problem is that it sets the class for the UL wraptag and not for LI breaks. I’ll ask if there’s a way to set a class for the LIs on the CBS thread, as you suggested. Thanks!

Offline

#4 2009-10-19 18:23:11

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

Re: Defining LI class with cbs_category_list

No, you cannot have classes for lis. You can however hard code it if it is a static site.


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

Offline

#5 2009-10-19 18:36:47

CharlesCountyArtsAlliance
New Member
Registered: 2009-10-19
Posts: 6

Re: Defining LI class with cbs_category_list

I thought that might be the case. I may end up having to do that anyway, because one of the sections links to a page outside of the TP database, and I can’t think of a way to append it to the section_list output. And it would certainly allow gho_alternation to work.

Thanks!

Offline

#6 2009-10-19 18:59:00

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Defining LI class with cbs_category_list

Have you considered going the other way, i.e. using txp:category_list’s form attribute together with gho_alternation and then adding the desired element the cbs tag outputs by means of other tags/plugins/PHP?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB