Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#131 2020-02-05 14:26:46

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

Re: Dev news

etc wrote #321522:

Try <txp:pages pg="pg" total="100" /> instead.

Okay, that makes sense and is important info to go in the docs, thanks. Doing that makes the page extremity whatever I set, even if it’s beyond the number of pages I have, and fixes the missing ‘1’ thing. That’s cool.

So for people that are using this to paginate regular Txp articles, they should always use the pg="pg" attribute, and either:

a) omit the outer total attribute to let Txp calculate the maximum.
b) use the outer total attribute if they want a fixed maximum number of pages.

That clears one thing up. Just the thing about the total in the central <txp:pages> tag to go.

Edit: The ‘Edit 2’ in my post above was me being stupid. Altering the step in the central <txp:pages> tag requires an adjustment in the ellipses tags either side of it to balance it. so they needed to be:

        <txp:pages shift="-7">...</txp:pages>
        <txp:pages total shift="3" break=" "><txp:yield item="page" /></txp:pages>
        <txp:pages shift="7">...</txp:pages>

Sorry for the false info.

Last edited by Bloke (2020-02-05 14:54:59)


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

#132 2020-02-05 16:52:43

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

Re: Dev news

Bloke wrote #321523:

So for people that are using this to paginate regular Txp articles, they should always use the pg="pg" attribute, and either:

a) omit the outer total attribute to let Txp calculate the maximum.
b) use the outer total attribute if they want a fixed maximum number of pages.

Not exactly, sorry. Explicitly setting pg="pg" does not reset total, it acts like any other pg value, leaving you the freedom to abuse it (and create meaningless txp links). To reset to defaults, use valueless pg (then total will be ignored): <txp:pages pg />.

That clears one thing up. Just the thing about the total in the central <txp:pages> tag to go.

You’ll probably need to adjust the ellipses shift, to avoid it prematurely disappear when close to the extremities: shift = min (7, current - 2) or something like that. The total number of remaining pages is given by <txp:newer/older total />.

Offline

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

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

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: 9,726
Website

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

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

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: 9,726
Website

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: 8,270
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Online

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

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,270
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Online

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

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

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

Board footer

Powered by FluxBB