Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-12-30 21:52:06

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

testing for first and last article in a category

Hi is there a way to test for the most recent and oldest article within a category?

I would like something like this.

<If most recent article in category >
some content here
</if most recent>
<If oldest article in this category >
some content here
</if oldest>
<else >
so content here
</else

thanks


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2011-12-30 21:58:58

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: testing for first and last article in a category

I mean how could i get the <txp:if_last_article> and <txp:if_first_article> to be limited by category?


its a bad hen that wont scratch itself.
photogallery

Offline

#3 2011-12-30 22:45:15

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: testing for first and last article in a category

If I’m not mistaken you can use those tags as you suggest as long as your are either:

  • in a category list context, e.g. the url has ?c=your-category-name in it, or
  • you filter the articles that can show with txp:article_custom category="your-category-name". You can then use if_first_article and if_last_article inside the txp:article_custom container or form.

TXP Builders – finely-crafted code, design and txp

Online

#4 2011-12-31 13:04:57

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: testing for first and last article in a category

thats jakob,

this is what I’m trying to do:

<ul id="previous-next">
<li id="n-previous">
<txp:if_last_article>&nbsp;<txp:else />
<txp:if_first_article>&nbsp;<txp:else />
<txp:if_individual_article>
<txp:smd_prev category='<txp:if_variable name="cat"><txp:variable name="cat" /></txp:if_variable>' datasort="posted, category1, category2"  >
<txp:smd_link_to_prev urlvars="cat">&laquo; Previous</txp:smd_link_to_prev>
</txp:smd_prev>
<txp:else />
<div class="older"><txp:older>Older Projects &raquo;</txp:older></older>
</if_last_article>
</if_first_article>
</txp:if_individual_article>
</li>
<li id="n-next">
<txp:if_last_article>&nbsp;<txp:else />
<txp:if_first_article>&nbsp;<txp:else />
<txp:if_individual_article>
<txp:smd_next category='<txp:if_variable name="cat"><txp:variable name="cat"   /></txp:if_variable>' datasort="posted, category1, category2" >
   <txp:smd_link_to_next urlvars="cat">&laquo; Next</txp:smd_link_to_next>
</txp:smd_next>
<txp:else />
<div class="newer"><txp:newer>&laquo;Newer Projects </txp:newer></div>
</if_last_article>
</if_first_article></txp:if_individual_article>
</li> </ul> <!-- end previous-next -->

But it doesn’t work. It only adds the &nbsp; everytime, regardless of whether the article is first last or not.

Last edited by kvnmcwebn (2011-12-31 13:08:33)


its a bad hen that wont scratch itself.
photogallery

Offline

#5 2011-12-31 16:00:45

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: testing for first and last article in a category

I think i’m just going to have to use a lightbox because that will solve the prev next problem and there’s not that much text along with these images anyway.


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB