Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
<txp:older /> inside of <txp:older> issue
Am I doing something wrong here?
<txp:older>
<div class="nav-link prev">« <a href="<txp:older />"><txp:text item="older" /></a></div></txp:older>
<txp:newer>
<div class="nav-link next"><a href="<txp:newer />"><txp:text item="newer" /></a> »</div>
</txp:newer>
I think everything’s OK, and I got that from the TXP wiki, but it’s generating this markup:
<a href="http://www.friendlyskies.net/?pg=2">
<div class="nav-link prev">«
<a href="http://www.friendlyskies.net/?pg=2">Older</a>
</div>
</a>
…which obviously has an issue and fails W3C validation.
Last edited by maruchan (2011-10-28 03:54:56)
Offline
Re: <txp:older /> inside of <txp:older> issue
maruchan wrote:
Am I doing something wrong here?
You are not doing anything wrong, it’s just that the example in the wiki is incorrect. The older and the newer tags will always output a HTML link when used as a container, and anything wrapped in the tags will be used as the link text. There is no conditional mode as suggested.
Instead you could use variables to power the conditional part i.e.
<!--
Populate variables named next and prev
-->
<txp:variable name="next" value='<txp:older />' />
<txp:variable name="prev" value='<txp:newer />' />
<!--
Check if there are older/newer entries
-->
<txp:if_variable name="prev" value="">
<txp:else />
<div>
<a href="<txp:variable name="prev" />">Newer articles</a>
</div>
</txp:if_variable>
<txp:if_variable name="next" value="">
<txp:else />
<div>
<a href="<txp:variable name="next" />">Older articles</a>
</div>
</txp:if_variable>
Offline
#3 2011-10-28 14:28:32
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: <txp:older /> inside of <txp:older> issue
Please note the difference between txp:newer or txp:older and txp:link_to_prev or txp:link_to_next.
For <txp:older>
the tag references says:
An article list consists of the assigned number of articles set by the article tag. If there are no articles available having older status (articles ranked lower, or later, in the present sort criteria than the present bottom of page article)
<txp:older>
will not display unless the showalways attribute is set to 1. It is normally seen used in tandem with newer.
Offline
Re: <txp:older /> inside of <txp:older> issue
Ah, thanks for the info & code. That makes sense.
Offline