Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Complex Pagination using Newer/Older with Shift
Ah, OK thanks – well that was easy (it’s fixed now).
For reference this is the working code:
<txp:pages pg link="" showalways="2" evaluate="6,3,9,5,7">
<nav class="paginator" aria-label="<txp:text item="page_nav" />">
<txp:newer showalways><a rel="prev" href="<txp:yield item="url" />"><txp:text item="prev" /></a></txp:newer>
<ul class="pagination">
<txp:newer shift><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:newer>
<txp:newer shift="-2"><li role="separator" aria-label="<txp:text item="more_pages" />">…</li></txp:newer>
<txp:newer total shift="2"><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:newer>
<txp:pages><li class="current"><b aria-current="page"><txp:yield item="page" /></b></li></txp:pages>
<txp:older total shift="2"><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:older>
<txp:older shift="-2"><li role="separator" aria-label="<txp:text item="more_pages" />">…</li></txp:older>
<txp:older shift><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:older>
</ul>
<txp:older showalways><a rel="next" href="<txp:yield item="url" />"><txp:text item="next" /></a></txp:older>
</nav>
</txp:pages>
Offline
Re: Complex Pagination using Newer/Older with Shift
Bloke wrote #326347:
When you introduced
<txp:text>
above those in the outer<nav>
, you’ve pushed all the numerical indexes down by one.
Would introducing some ignore
attribute be handy? Generally, tags like <txp:text />
output something, so testing them for emptiness is useless.
Edit: though, for positional tags this could be confusing.
Offline
Re: Complex Pagination using Newer/Older with Shift
etc wrote #326369:
Would introducing some
ignore
attribute be handy? Generally, tags like<txp:text />
output something, so testing them for emptiness is useless.
Seems like a good idea.
Offline
Offline
Re: Complex Pagination using Newer/Older with Shift
etc wrote #326369:
Would introducing some
ignore
attribute be handy? Generally, tags like<txp:text />
output something, so testing them for emptiness is useless.Edit: though, for positional tags this could be confusing.
Hmm… not dismissing this out of hand, but doesn’t this introduce yet another cognitive complexity on the end-users side ? (I mean, already phil got slightly lost in deciding what is been evaluated in the code above, I fear an ignore
attribute may run into similar problems)
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Complex Pagination using Newer/Older with Shift
phiw13 wrote #326372:
Hmm… not dismissing this out of hand, but doesn’t this introduce yet another cognitive complexity on the end-users side ?
It does. An easier (end-user wise) option might be some global order
attribute that alters the order the tags are processed in inside each block. Code-wise it’s another story, though…
Offline
Re: Complex Pagination using Newer/Older with Shift
etc wrote #326374:
An easier (end-user wise) option might be some global
order
attribute that alters the order the tags are processed in inside each block.
Finally done, via a new <txp:tag[n] />
syntax, to be approved/chosen by the community:
<!-- copy the whole block -->
<txp:variable name="test" add output /> (outputs 6)
<txp:variable[2] name="test" output>5</txp:variable> (outputs 5)
<txp:variable[1] name="test" add output /> (outputs 1)
Offline
Re: Complex Pagination using Newer/Older with Shift
etc wrote #326433:
Finally done, via a new
<txp:tag[n] />
syntax, to be approved/chosen by the community:
Which means Phil can set the tags processing priority independently of addition/deletion another tags:
<txp:pages pg link="" showalways="2">
<nav class="paginator" aria-label="<txp:text item="page_nav" />">
<txp:newer showalways><a rel="prev" href="<txp:yield item="url" />"><txp:text item="prev" /></a></txp:newer>
<ul class="pagination">
<txp:newer[2] shift><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:newer>
<txp:newer shift="-2"><li role="separator" aria-label="<txp:text item="more_pages" />">…</li></txp:newer>
<txp:newer[3] total shift="2"><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:newer>
<txp:pages[1]><li class="current"><b aria-current="page"><txp:yield item="page" /></b></li></txp:pages>
<txp:older[3] total shift="2"><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:older>
<txp:older shift="-2"><li role="separator" aria-label="<txp:text item="more_pages" />">…</li></txp:older>
<txp:older[2] shift><li><a href="<txp:yield item="url" />"><txp:yield item="page" /></a></li></txp:older>
</ul>
<txp:older showalways><a rel="next" href="<txp:yield item="url" />"><txp:text item="next" /></a></txp:older>
</nav>
</txp:pages>
Offline
Re: Complex Pagination using Newer/Older with Shift
Thanks Oleg – is this method less taxing on resources than using the evaluate method – or it is negligible difference?
Offline
Offline
Re: Complex Pagination using Newer/Older with Shift
Ah, OK – great. I’ll amend my theme to use the above example when 4.8.4 lands, since I think this syntax is a little easier to read and understand.
Offline
Re: Complex Pagination using Newer/Older with Shift
etc wrote #326433:
Finally done, via a new
<txp:tag[n] />
syntax, to be approved/chosen by the community:
This look highly interesting for the type of constructs mentioned in this thread.
If I understand it right, <txp:tag[1] />
is processed first, then <txp:tag[2] />
, and last un-“labeled” (counted) tag <txp:tag />
? I think that syntax is OK.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline