Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-06-21 10:47:44

FireFusion
Member
Registered: 2005-05-10
Posts: 698

How to produce this the easy way?

Using the following category structure…

Master Parent Category
# Category
## Sub category
## Sub category
## Sub category
# Category
## Sub category
## Sub category
## Sub category
# Category
## Sub category
## Sub category
## Sub category

I’d like to output the following, excluding the master parent category.

<ul>
<li class="cat">Category</li>
<li><a href="#">Sub category</a></li>
<li><a href="#">Sub category</a></li>
<li><a href="#">Sub category</a></li>
<li class="cat">Category</li>
<li><a href="#">Sub category</a></li>
<li><a href="#">Sub category</a></li>
<li><a href="#">Sub category</a></li>
<li class="cat">Category</li>
<li><a href="#">Sub category</a></li>
<li><a href="#">Sub category</a></li>
<li><a href="#">Sub category</a></li>
</ul>

Does anyone know a plugin that can do this?

Last edited by FireFusion (2009-06-21 10:48:17)

Offline

#2 2009-06-21 10:53:18

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,529
Website GitHub Twitter

Re: How to produce this the easy way?

Hi

Is category_tree can solve your problem?

Offline

#3 2009-06-21 11:03:56

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: How to produce this the easy way?

What are you using currently to produce the category list?

Offline

#4 2009-06-21 12:32:47

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

Re: How to produce this the easy way?

<txp:category_list parent="master-parent" exclude="master-parent" children="0" wraptag="ul" break="">
	<li class="cat"><txp:category title="1" /></li>
	<txp:category_list parent='<txp:category />' exclude='<txp:category />' break="">
		<li><txp:category title="1" link="1" /></li>
	</txp:category_list>
</txp:category_list>

Offline

#5 2009-06-21 12:57:55

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: How to produce this the easy way?

Well – I was going to post something like that, but as usual, Els beat me to it with better code!

Els – do we have something like this on TXP Tips? I don’t think so – shall I add this example?

Offline

#6 2009-06-21 13:19:48

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

Re: How to produce this the easy way?

jstubbs wrote:

Els – do we have something like this on TXP Tips? I don’t think so – shall I add this example?

If you think it’s useful :) Here is a way to do it using nested lists (better IMO):

<txp:category_list parent="master-parent" exclude="master-parent" children="0" wraptag="ul" break="">
	<li class="cat"><txp:category title="1" />
	<txp:category_list parent='<txp:category />' exclude='<txp:category />' wraptag="ul" break="" class="subcat_list">
		<li><txp:category title="1" link="1" /></li>
	</txp:category_list>
	</li>
</txp:category_list>

Offline

#7 2009-06-21 14:08:33

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: How to produce this the easy way?

Great thanks :)

Anyway to highlight the active category with that?

Offline

#8 2009-06-21 14:35:23

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

Re: How to produce this the easy way?

FireFusion wrote:

Anyway to highlight the active category with that?

I think this should do it:

<li<txp:if_category name='<txp:category />'> class="active"</txp:if_category>><txp:category title="1" link="1" /></li>

Offline

#9 2011-07-06 08:16:25

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: How to produce this the easy way?

Is it enough to copy and paste the code

<txp:category_list parent="master-parent" exclude="master-parent" children="0" wraptag="ul" break=""> <li class="cat"><txp:category title="1" /> <txp:category_list parent='<txp:category />' exclude='<txp:category />' wraptag="ul" break="" class="subcat_list"> <li><txp:category title="1" link="1" /></li> </txp:category_list> </li> </txp:category_list>

to make it work? Or something else should be added? It just does not work.

Offline

Board footer

Powered by FluxBB