Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-03-17 02:54:57

anndylala
New Member
Registered: 2018-03-17
Posts: 1

Issue with categories that do not have any assigned articles yet

I have a two column design. On the left is the main content, and on the right is the navigation such as category links etc.

When I click on a category that does not have any assigned articles, I am sent to a page that throws my right column all the way to the left and it appears that the main content div is not even on the page.

Does anyone know how I can display a message that says something like “no articles in this cateogry yet” when a category without any articles is clicked on?

Thanks!!

Offline

#2 2018-03-17 04:51:16

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

Re: Issue with categories that do not have any assigned articles yet

This is a variation of something I came up with previously (that I had totally forgotten about until I searched the forums):

<section>

  <header>										
    <h2>Category Archives for <txp:category title="1" /></h3>
  </header>

  <txp:variable name="contains-articles" value="false" />

  <txp:article section="article" limit="1">
    <txp:variable name="contains-articles" value="true" />
  </txp:article>

  <txp:if_variable name="contains-articles" value="false">
    <p>There are no articles in this category. Check back later.</p>
  <txp:else />
    <txp:article break="li" form="date" limit="999" section="article" wraptag="ul" />
  </txp:if_variable>

</section>

You can see it in action here.

Edit: An earlier version of this used adi_calc until I realized it was totally unnecessary because we were testing a true/false: whether or not there were articles.

Last edited by michaelkpate (2018-03-17 05:09:55)

Offline

#3 2018-03-17 10:41:53

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 1,550
Website

Re: Issue with categories that do not have any assigned articles yet

michaelkpate wrote #310055:

This is a variation of something I came up with previously (that I had totally forgotten about until I searched the forums):

<section>...

With TXP 4.7 beta you can simplify that:

<txp:evaluate>
  <txp:article break="li" form="date" limit="999" section="article" wraptag="ul" />
<txp:else />
  <p>There are no articles in this category. Check back later.</p>
</txp:evaluate>

Offline

#4 2018-03-17 11:46:53

etc
Developer
Registered: 2010-11-11
Posts: 2,950
Website

Re: Issue with categories that do not have any assigned articles yet

phiw13 wrote #310064:

With TXP 4.7 beta you can simplify that:

or even this:

<txp:article break="li" limit="999" section="article" wraptag="ul" />
  <txp:output_form form="date" />
<txp:else />
  <p>There are no articles in this category. Check back later.</p>
</txp:article>

etc_[ query | search | pagination | date | tree | cache ]

Offline

Board footer

Powered by FluxBB