Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-03-30 20:25:14

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 152
Website

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

#2 2018-03-31 01:32:46

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

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

#3 2018-03-31 14:50:26

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 152
Website

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

#4 2018-03-31 15:27:39

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 152
Website

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

#5 2018-03-31 16:08:52

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

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

#6 2018-03-31 16:14:21

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 152
Website

Re: list of articles in a section

That works perfectly. Thank you!

Offline

#7 2018-03-31 17:04:33

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

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

Board footer

Powered by FluxBB