Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2020-10-13 08:46:26

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#38 2020-10-14 07:25:27

etc
Developer
Registered: 2010-11-11
Posts: 5,257
Website GitHub

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

#39 2020-10-14 07:27:43

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#40 2020-10-14 07:29:11

etc
Developer
Registered: 2010-11-11
Posts: 5,257
Website GitHub

Re: Complex Pagination using Newer/Older with Shift

philwareham wrote #326370:

Seems like a good idea.

Ok, to think about.

Offline

#41 2020-10-14 07:39:48

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,248
Website

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

#42 2020-10-14 08:13:06

etc
Developer
Registered: 2010-11-11
Posts: 5,257
Website GitHub

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

#43 2020-10-16 10:36:47

etc
Developer
Registered: 2010-11-11
Posts: 5,257
Website GitHub

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

#44 2020-10-16 11:34:07

etc
Developer
Registered: 2010-11-11
Posts: 5,257
Website GitHub

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

#45 2020-10-16 11:36:53

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#46 2020-10-16 11:41:44

etc
Developer
Registered: 2010-11-11
Posts: 5,257
Website GitHub

Re: Complex Pagination using Newer/Older with Shift

philwareham wrote #326435:

Thanks Oleg – is this method less taxing on resources than using the evaluate method – or it is negligible difference?

Roughly the same, it actually uses evaluate.

Offline

#47 2020-10-16 11:44:03

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#48 2020-10-16 12:09:35

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,248
Website

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

Board footer

Powered by FluxBB