Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2012-01-28 19:27:08
- markus_falk
- Member
- Registered: 2012-01-14
- Posts: 11
exclude empty categories [solved]
is there a way to use the category list but exclude empty categories from it? I checked on a few plugins that did exactly that but with them I wasn’t able to change much of the HTML. I need the following output:
<ul data-role="listview" data-theme="c" data-divider-theme="a" data-inset="true">
<txp:category_list wraptag="" break="">
<li> <txp:category title="1" link="1" /> </li>
</txp:category_list>
</ul>
thanks alot :)
Last edited by markus_falk (2012-01-28 19:33:26)
Offline
#2 2012-01-28 19:32:56
- markus_falk
- Member
- Registered: 2012-01-14
- Posts: 11
Re: exclude empty categories [solved]
I swear I tried the very same thing for hours and hours …
http://forum.textpattern.com/viewtopic.php?id=35466
thanks to those contributers :)
Offline
Re: exclude empty categories [solved]
You could use article_custom and variable tags in the category listing. For example, something like:
<txp:category_list break="" wraptag="">
<!--
Check if the category has any articles using article_custom.
Populate "has_articles" variable with "true" if there are articles.
-->
<txp:variable name="has_articles"><txp:article_custom category='<txp:category />' limit="1">true</txp:article_custom></txp:variable>
<txp:if_variable name="has_articles" value="">
<!--
No articles, skip.
-->
<txp:else />
<li><txp:category title="1" link="1" /></li>
</txp:if_variable>
</txp:category_list>
Offline
Pages: 1