Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-04 23:27:09

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

Show only Categories 'used'

Hi, I want to show only Categories that are currently used. I mean, Categories that have, at least, 1 article (Inside them)

I hope you understand me.

Thanks in advance.

Offline

#2 2009-02-05 00:10:12

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

Re: Show only Categories 'used'

I did it like this:

<txp:category_list wraptag="ul" break="">
	<txp:variable name="hasarticle" value='<txp:article_custom category=''<txp:category />'' limit="1" />' />
	<txp:if_variable name="hasarticle" value="">
	<txp:else />
		<li><txp:category title="1" link="1" class='<txp:if_category name=''<txp:category />''>current</txp:if_category>' /></li>
	</txp:if_variable>
</txp:category_list>

Offline

#3 2009-02-05 00:19:02

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

Re: Show only Categories 'used'

OMG Els, you rules! It’s exactly what I wanted. Thank you very much. God bless you!

Offline

Board footer

Powered by FluxBB