Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
list of articles in a section
I haven’t hacked on Textpattern code in years, and all knowledge has evaporated. I have a sidebar on my site for all pages that has a navigation aid:
<txp:cbs_category_list section="tools" wraptag="ul" break = "li" showcount="true" label="<b>Tools</b>" class="categorylist" activeclass="categorycurrent" />
which is a plugin that makes a list of links to categories. What I want instead is a list of links to the individual articles. How do I get that done?
Offline
Re: list of articles in a section
skewray wrote #310480:
What I want instead is a list of links to the individual articles.
Do you want them sorted by category…
<txp:category_list section="tools" wraptag="" break="">
<txp:if_different>
<h3>
<txp:category />
</h3>
</txp:if_different>
<txp:article_custom category='<txp:category />' break="li" form="[yourform]" limit="999" section="tools" wraptag="ul" />
</txp:category_list>
or just a complete list of articles?
<txp:article section="tools" wraptag="ul" break = "li" form="[yourform]" limit="999" />
[yourform]
<txp:permlink><txp:title /></txp:permlink> - <txp:posted format="%B %e, %Y" />
Offline
Re: list of articles in a section
Thank you, Michael. This is perfect. I was thinking just a list, but if I ever have a lot, I would want to have categories. I’ll put in both, and comment out the category version until I have more.
Offline
Re: list of articles in a section
So, I tried both. The fancy version prints headers for all the categories, even if there are no articles in the “tools” section. The simple version ignores the section=“tools” and always gave a list of articles from the section of the displayed page.
Offline
Re: list of articles in a section
skewray wrote #310512:
The simple version ignores the section=“tools” and always gave a list of articles from the section of the displayed page.
Try this. It uses article_custom instead of article.
<txp:article_custom section="tools" wraptag="ul" break = "li" form="[yourform]" limit="999" />
Offline
Re: list of articles in a section
That works perfectly. Thank you!
Offline
Re: list of articles in a section
skewray wrote #310512:
The fancy version prints headers for all the categories, even if there are no articles in the “tools” section.
This version skips all the empty categories and if there are no articles in the section, you get a message. I adapted something I posted a couple of weeks ago.
<header>
<h2>Tools</h2>
</header>
<txp:variable name="section-has-articles" value="false" />
<txp:article_custom section="tools" limit="1">
<txp:variable name="section-has-articles" value="true" />
</txp:article_custom>
<txp:if_variable name="section-has-articles" value="false">
<p>There are no articles in this section. Check back later.</p>
<txp:else />
<txp:category_list section="article" wraptag="" break="">
<txp:variable name="category-has-articles" value="false" />
<txp:article_custom section="tools" category='<txp:category />' limit="1">
<txp:variable name="category-has-articles" value="true" />
</txp:article_custom>
<txp:if_variable name="category-has-articles" value="true">
<h3><txp:category title="1" /></h3>
<txp:article_custom category='<txp:category />' break="li" form="[yourform]" limit="999" section="tools" wraptag="ul" />
</txp:if_variable>
</txp:category_list>
</txp:if_variable>
</section>
Offline
Pages: 1