Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[howto] Conditional code for next/prev articles using variables
This shows the next and previous links only if they exist, allowing the addition of blocks of code within the conditional statement, rather than just a link to the next or previous article.
It’s extremely useful if the prev/next tags on your site need to include layout code/structure.
<txp:variable name="hasprev" value='<txp:prev_title />' />
<txp:variable name="hasnext" value='<txp:next_title />' />
<txp:if_variable name="hasnext" value="">
<p class="quiet">This is the latest article</p>
<txp:else />
<p class="next"><txp:link_to_next ><txp:next_title /></txp:link_to_next></p>
</txp:if_variable>
<txp:if_variable name="hasprev" value="">
<p class="quiet">No previous articles</p>
<txp:else />
<p class="prev"><txp:link_to_prev ><txp:prev_title /></txp:link_to_prev></p>
</txp:if_variable>
Offline