Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#133 2020-02-05 17:09:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Dev news

Thanks for the clarification on the pg attribute. That definitely needs documenting :)

And, yeah, the ellipses thing was me being a tool, so ignore that.

I’m still curious why, when on some page such as 21, this:

<txp:pages pg evaluate="2">
    <nav>
        <txp:newer showalways>&laquo;</txp:newer>
        <txp:pages total shift="2" break=" "><txp:yield item="page" /></txp:pages>
        <txp:older showalways>&raquo;</txp:older>
    </nav>
</txp:pages>

outputs:

 « 19 20 21 22 23 » 

But removing the total attribute from the central call to <txp:pages> outputs:

« 23 »

Is valueless total setting something up internally that allows the yield to work?


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

#134 2020-02-05 17:19:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Dev news

Also, supplying a value to total in the above example (however invalid that may be) causes Textpattern Notice: unknown_attribute: shift while_parsing_page_form: default, none.

So this attribute can only be valueless when used inside another <txp:pages> wrapper, right?

If I understand correctly:

  1. shift inside <txp:newer/older> is an offset from the end. It can either be valueless (meaning one value ‘in’ from the extremity) or a negative number to move ‘in’ that many values from the extremity.
  2. shift cannot be a positive value inside <txp:newer/older>.
  3. shift inside <txp:pages total> represents a width +/- either side of the current page.
  4. shift inside <txp:pages> will add/subtract the value to the current page.

Is that accurate?

Last edited by Bloke (2020-02-05 17:22:13)


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

#135 2020-02-05 18:08:24

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

Re: Dev news

It’s complicated :-)

Bloke wrote #321532:

Also, supplying a value to total in the above example (however invalid that may be) causes Textpattern Notice: unknown_attribute: shift while_parsing_page_form: default, none.

Basically, pg and total attributes of <txp:pages /> are used only for setting pagination parameters, not for outputting something. Hence txp does not see any use for shift in <txp:pages total="10" shift /> tag and complains about it. We could treat this case as ‘set, output and reset’ though, suggestions welcome.

So this attribute can only be valueless when used inside another <txp:pages> wrapper, right?

Exactly, to modify shift behaviour.

If I understand correctly:

  1. shift inside <txp:newer/older> is an offset from the end. It can either be valueless (meaning one value ‘in’ from the extremity) or a negative number to move ‘in’ that many values from the extremity. YES
  2. shift cannot be a positive value inside <txp:newer/older>. IT CAN AND WILL BE OFFSET FROM THE CURRENT PAGE
  3. shift inside <txp:pages total> represents a width +/- either side of the current page. YES, AND LIKEWISE IN NEWER/OLDER
  4. shift inside <txp:pages> will add/subtract the value to the current page. YES, EVEN A LIST OF VALUES, AND LIKEWISE IN NEWER/OLDER

Offline

#136 2020-02-06 09:02:04

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

Re: Dev news

Bloke wrote #321531:

And, yeah, the ellipses thing was me being a tool, so ignore that.

Welcome limit attribute! Now you should get fast navigation with

<txp:pages total="200" evaluate="3,7,5">
    <nav aria-label="<txp:text item="page_nav" />">
        <txp:newer showalways><span aria-label="Go to previous page">&laquo;</span></txp:newer>
        <txp:newer shift><span aria-label="Go to first page"><txp:yield item="page" /></span></txp:newer>
        <txp:newer shift="5-3" limit="1"><span role="separator" aria-label="More pages">…</span></txp:newer>
        <txp:pages total shift="2"><span aria-label="Go to page <txp:yield item="page" />"><txp:yield item="page" /></span></txp:pages>
        <txp:older shift="5-3" limit="1"><span role="separator" aria-label="More pages">…</span></txp:older>
        <txp:older shift><span aria-label="Go to last page"><txp:yield item="page" /></span></txp:older>
        <txp:older showalways><span aria-label="Go to next page">&raquo;</span></txp:older>
    </nav>
</txp:pages>

Offline

#137 2020-02-06 09:35:00

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Dev news

Oooh, limit. Nice! Works a treat, thank you.


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

#138 2020-02-06 10:02:52

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Dev news

etc wrote #321536:

Welcome limit attribute! Now you should get fast navigation with

<txp:pages total="200" evaluate="3,7,5">...

That works like a treat! Is there a way to have the first page showing all the time? Including showalways in <txp:newer shift showalways><span aria-label="Go to first page"><txp:yield item="page" /></span></txp:newer> seem to be repeating the nav.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#139 2020-02-06 10:07:56

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Dev news

Also, the &raquo; in <txp:older showalways><span aria-label="Go to next page">&raquo;</span></txp:older> is understandably showing always but is there a way to make it not show when somebody is on the last page? I can of course give it a class and use display:none if this is not possible.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#140 2020-02-06 10:13:14

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

Re: Dev news

colak wrote #321538:

Is there a way to have the first page showing all the time?

You mean to be linked all the time?

<txp:newer shift link><span aria-label="Go to first page"><txp:yield item="page" /></span></txp:newer>
colak wrote #321539:

Also, the &raquo; in <txp:older showalways><span aria-label="Go to next page">&raquo;</span></txp:older> is understandably showing always but is there a way to make it not show when somebody is on the last page?

Remove showalways :)- though no, it’s not working. Lemme see…

<txp:pages total="200" evaluate="2,8,3,7,5">
    <nav aria-label="<txp:text item="page_nav" />">
        <txp:newer><span aria-label="Go to previous page">&laquo;</span></txp:newer>
        <txp:newer shift link><span aria-label="Go to first page"><txp:yield item="page" /></span></txp:newer>
        <txp:newer shift="5-3" limit="1"><span role="separator" aria-label="More pages">…</span></txp:newer>
        <txp:pages total shift="2"><span aria-label="Go to page <txp:yield item="page" />"><txp:yield item="page" /></span></txp:pages>
        <txp:older shift="5-3" limit="1"><span role="separator" aria-label="More pages">…</span></txp:older>
        <txp:older shift link><span aria-label="Go to last page"><txp:yield item="page" /></span></txp:older>
        <txp:older><span aria-label="Go to next page">&raquo;</span></txp:older>
    </nav>
</txp:pages>

Offline

#141 2020-02-06 10:47:14

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

Re: Dev news

Would it be me, the previous showalways functionality (show even if the page is out of bounds) would be delegated to false part of <txp:else />. And showalways would mean ‘show even if already shown’. But it could require updating old <txp:newer/older showalways /> constructions. Should I?

Offline

#142 2020-02-06 11:14:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Dev news

Difficult to say. There are many use cases for showalways, one being that you want to show the ‘previous’ or ‘next’ links but grey them out if there are no more pages in the indicated direction.

Are you saying we could add <txp:else /> support to newer/older so that if the tag would result in an out-of-bounds situation you follow the else branch?

How would that look? At the moment, without an if_newer/older conditional, switching (say) a class when an out-of-bounds situation arises is a bit of a chore as you need to evaluate it first. An ‘else’ might be nice, although I guess you would still have to potentially repeat the content, e.g.:

<txp:newer link>
    <txp:yield item="page" />
<txp:else />
    <txp:yield item="page" class="disabled" />
</txp:newer>

?

How would we honour link in the else branch? Ignore it because there’s nothing to link to?

And folding showalways in, how would that change things? Would that always follow ‘true’ – in which case, how do you style it differently if there’s no next page? Or would we deprecate showalways if we add conditional support, because it’s no longer relevant? (it’s arguably a hack).

Dunno. Whatever makes most sense for the majority of use cases, I guess.


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

#143 2020-02-06 12:01:54

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

Re: Dev news

Done, since it’s more flexible and better overall. So, the ancient <txp:older showalways>&raquo;</txp:older> becomes

<txp:older showalways>
    &raquo;
<txp:else />
    &raquo;
</txp:older>

If the older page exists, it will be linked and always shown, even if some other pagination tag has already output it. Otherwise, unlinked false part will be output, with extra possibility to style it differently. This is the only change required for bwc, all other functionality being new.

This does not deprecate showalways attribute, since its role now is to always show valid links even if they have already been output by other tags. All invalid links will be processed via <txp:else />.

Offline

#144 2020-02-06 14:08:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Dev news

colak wrote #321538:

Is there a way to have the first page showing all the time?

etc wrote #321540:

You mean to be linked all the time?

Yes, except when somebody is actually on the first page, at which case it should just appear as unlinked text:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB