Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-01-10 11:41:22
- leafy_loader
- Member
- Registered: 2008-09-25
- Posts: 96
Omit articles assigned to categories...
The main navigation has a top level, consisting of section names, and a sub level, consisting of category names.
If the user clicks on a top level link I want the page to display articles only assigned to that section and not to a category. If a sub level link is clicked then only articles assigned to the category are displayed.
I can achieve the latter quite easily but I can’t work out how to display articles that are assigned to sections only and not categorised.
<div class="mainContent">
<txp:if_section name="default">
<txp:article_custom section="home" />
<txp:else />
<h1><txp:section title='1' /></h1>
<txp:article sort="position asc">
<txp:if_category>
<h3><txp:title /></h3>
<txp:body />
<txp:else />
<h3><txp:title /></h3>
<txp:body />
</txp:if_category>
</txp:article>
</txp:if_section>
</div>
I think I’m over complicating things.
Offline
Re: Omit articles assigned to categories...
Hi
Have you tried using txp:variable like this (put it in an article form):
<txp:variable name="thecat" value='<txp:category1 />' />
<txp:if_variable name="thecat" value="">
here article without category
<txp:else />
here article with a category
</txp:variable>
Last edited by Dragondz (2010-01-10 13:59:00)
Offline
#3 2010-01-10 15:42:26
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Omit articles assigned to categories...
Or just change <txp:if_category>
in your code to <txp:if_article_category>
:)
Last edited by els (2010-01-10 16:49:02)
Offline
#4 2010-01-10 16:31:02
- leafy_loader
- Member
- Registered: 2008-09-25
- Posts: 96
Re: Omit articles assigned to categories...
I’ve taken your idea and created this;
<div class=“mainContent”>
<txp:if_section name=“default”>
<txp:article_custom section=“home” />
<txp:else />
<h1><txp:section title=‘1’ /></h1>
<txp:article sort=“position asc”>
<txp:variable name=“artCat” value=’<txp:category1 /><txp:category2 />’ />
<txp:if_variable name=“artCat” value=”“>
<h3><txp:title /></h3>
<txp:body />
<txp:else />
<txp:if_category>
<h3><txp:title /></h3>
<txp:body />
</txp:if_category>
</txp:if_variable>
</txp:article>
</txp:if_section>
</div>
Which works thanks. I wonder if there is a simpler solution?
Offline