Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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> <txp:else />
<txp:if_first_article> <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">« Previous</txp:smd_link_to_prev>
</txp:smd_prev>
<txp:else />
<div class="older"><txp:older>Older Projects »</txp:older></older>
</if_last_article>
</if_first_article>
</txp:if_individual_article>
</li>
<li id="n-next">
<txp:if_last_article> <txp:else />
<txp:if_first_article> <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">« Next</txp:smd_link_to_next>
</txp:smd_next>
<txp:else />
<div class="newer"><txp:newer>«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 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
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