Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 2,139
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 ?

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 3,934
Website

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: 3,934
Website

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: 3,934
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:

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,393
Website

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: 3,934
Website

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,393
Website

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: 2,139
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 ?

Offline

#49 2020-10-16 14:22:01

etc
Developer
Registered: 2010-11-11
Posts: 3,934
Website

Re: Complex Pagination using Newer/Older with Shift

philwareham wrote #326437:

this syntax is a little easier to read and understand.

More importantly, you don’t have to modify it (unlike with evaluate) when adding/deleting tags.

phiw13 wrote #326438:

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.

Absolutely, glad you find it useful.

Offline

#50 2020-10-16 14:38:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,775
Website

Re: Complex Pagination using Newer/Older with Shift

Wow. Fab idea, Oleg.

Does it only work inside container tags, or can it be used generally to, for example, run something on the 2nd pass without wrapping it in <txp:hide process="2">? (not suggesting we do that, it’s a genuine question for documentation purposes!)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB