Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#145 2020-02-06 14:18:51

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

Re: Dev news

etc wrote #321543:

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

Testing. Looks good!


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

Offline

#146 2020-02-06 14:48:21

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

Re: Dev news

Whoops found a problem.

This is the code I am testing

<txp:evaluate query='<txp:page_url type="pg" /> = 1'>
<txp:article_custom status="live" section="blog" c10="x" form="sticky_form" limit="30" />
</txp:evaluate>
<txp:article limit="10" c10="" listform="live_form" form="" />

<txp:pages total evaluate="3,7,5">
    <nav aria-label="<txp:text item="page_nav" />" class="pagination">
        <ul>
        <txp:newer showalways break="li"><span aria-label="Go to previous page">&#x2962;</span></txp:newer>
        <txp:newer shift break="li"><span aria-label="Go to first page"><txp:yield item="page" /></span></txp:newer>
        <txp:newer shift="5-3" limit="1" break="li"><span role="separator" aria-label="More pages">…</span></txp:newer>
        <txp:pages total shift="2" break="li"><span aria-label="Go to page <txp:yield item="page" />"><txp:yield item="page" /></span></txp:pages>
        <txp:older shift="5-3" limit="1" break="li"><span role="separator" aria-label="More pages">…</span></txp:older>
        <txp:older shift break="li"><span aria-label="Go to last page"><txp:yield item="page" /></span></txp:older>
        <txp:older showalways break="li"><span aria-label="Go to next page">&#x2964;</span></txp:older>
        </ul>
    </nav>
</txp:pages>

This is the confusing result of the pagination. Please note the opening a tag before the nav which closes just after the </nav>. there is also a number of largish number page links included but as there is no content between the a tags, they are only visible when viewing the source of the page.

<a href="http://dev.site.tld/blog/?pg=1">
    <nav aria-label="Page navigation" class="pagination">
<ul>
        <li><a href="http://dev.site.tld/blog/?pg=5"><span aria-label="Go to previous page">&laquo;</span></a></li>

        <li><a href="http://dev.site.tld/blog/?pg=2"><span role="separator" aria-label="More pages">…</span></a></li>
        <li><a href="http://dev.site.tld/blog/?pg=4"><span aria-label="Go to page 4">4</span></a></li>
        <li><a href="http://dev.site.tld/blog/?pg=5"><span aria-label="Go to page 5">5</span></a></li>
        <li><span aria-label="Go to page 6">6</span></li>
        <li><a href="http://dev.site.tld/blog/?pg=7"><span aria-label="Go to page 7">7</span></a></li>
        <li><a href="http://dev.site.tld/blog/?pg=8"><span aria-label="Go to page 8">8</span></a></li>
        <li><a href="http://dev.site.tld/blog/?pg=11"><span role="separator" aria-label="More pages">…</span></a></li>
        <li><a href="http://dev.site.tld/blog/?pg=169"><span aria-label="Go to last page">169</span></a></li>
        <li><a href="http://dev.site.tld/blog/?pg=7"><span aria-label="Go to next page">&raquo;</span></a></li>
</ul>
    </nav>
</a><a href="http://dev.site.tld/blog/?pg=3"></a><a href="http://dev.site.tld/blog/?pg=9"></a><a href="http://dev.site.tld/blog/?pg=10"></a><a href="http://dev.site.tld/blog/?pg=12"></a><a href="http://dev.site.tld/blog/?pg=13"></a><a href="http://dev.site.tld/blog/?pg=14"></a><a href="http://dev.site.tld/blog/?pg=15"></a><a href="http://dev.site.tld/blog/?pg=16"></a><a href="http://dev.site.tld/blog/?pg=17"></a><a href="http://dev.site.tld/blog/?pg=18"></a><a href="http://dev.site.tld/blog/?pg=19"></a><a href="http://dev.site.tld/blog/?pg=20"></a><a href="http://dev.site.tld/blog/?pg=21"></a><a href="http://dev.site.tld/blog/?pg=22"></a><a href="http://dev.site.tld/blog/?pg=23"></a><a href="http://dev.site.tld/blog/?pg=24"></a><a href="http://dev.site.tld/blog/?pg=25"></a><a href="http://dev.site.tld/blog/?pg=26"></a><a href="http://dev.site.tld/blog/?pg=27"></a><a href="http://dev.site.tld/blog/?pg=28"></a><a href="http://dev.site.tld/blog/?pg=29"></a><a href="http://dev.site.tld/blog/?pg=30"></a><a href="http://dev.site.tld/blog/?pg=31"></a><a href="http://dev.site.tld/blog/?pg=32"></a><a href="http://dev.site.tld/blog/?pg=33"></a><a href="http://dev.site.tld/blog/?pg=34"></a><a href="http://dev.site.tld/blog/?pg=35"></a><a href="http://dev.site.tld/blog/?pg=36"></a><a href="http://dev.site.tld/blog/?pg=37"></a><a href="http://dev.site.tld/blog/?pg=38"></a><a href="http://dev.site.tld/blog/?pg=39"></a><a href="http://dev.site.tld/blog/?pg=40"></a><a href="http://dev.site.tld/blog/?pg=41"></a><a href="http://dev.site.tld/blog/?pg=42"></a><a href="http://dev.site.tld/blog/?pg=43"></a><a href="http://dev.site.tld/blog/?pg=44"></a><a href="http://dev.site.tld/blog/?pg=45"></a><a href="http://dev.site.tld/blog/?pg=46"></a><a href="http://dev.site.tld/blog/?pg=47"></a><a href="http://dev.site.tld/blog/?pg=48"></a><a href="http://dev.site.tld/blog/?pg=49"></a><a href="http://dev.site.tld/blog/?pg=50"></a><a href="http://dev.site.tld/blog/?pg=51"></a><a href="http://dev.site.tld/blog/?pg=52"></a><a href="http://dev.site.tld/blog/?pg=53"></a><a href="http://dev.site.tld/blog/?pg=54"></a><a href="http://dev.site.tld/blog/?pg=55"></a><a href="http://dev.site.tld/blog/?pg=56"></a><a href="http://dev.site.tld/blog/?pg=57"></a><a href="http://dev.site.tld/blog/?pg=58"></a><a href="http://dev.site.tld/blog/?pg=59"></a><a href="http://dev.site.tld/blog/?pg=60"></a><a href="http://dev.site.tld/blog/?pg=61"></a><a href="http://dev.site.tld/blog/?pg=62"></a><a href="http://dev.site.tld/blog/?pg=63"></a><a href="http://dev.site.tld/blog/?pg=64"></a><a href="http://dev.site.tld/blog/?pg=65"></a><a href="http://dev.site.tld/blog/?pg=66"></a><a href="http://dev.site.tld/blog/?pg=67"></a><a href="http://dev.site.tld/blog/?pg=68"></a><a href="http://dev.site.tld/blog/?pg=69"></a><a href="http://dev.site.tld/blog/?pg=70"></a><a href="http://dev.site.tld/blog/?pg=71"></a><a href="http://dev.site.tld/blog/?pg=72"></a><a href="http://dev.site.tld/blog/?pg=73"></a><a href="http://dev.site.tld/blog/?pg=74"></a><a href="http://dev.site.tld/blog/?pg=75"></a><a href="http://dev.site.tld/blog/?pg=76"></a><a href="http://dev.site.tld/blog/?pg=77"></a><a href="http://dev.site.tld/blog/?pg=78"></a><a href="http://dev.site.tld/blog/?pg=79"></a><a href="http://dev.site.tld/blog/?pg=80"></a><a href="http://dev.site.tld/blog/?pg=81"></a><a href="http://dev.site.tld/blog/?pg=82"></a><a href="http://dev.site.tld/blog/?pg=83"></a><a href="http://dev.site.tld/blog/?pg=84"></a><a href="http://dev.site.tld/blog/?pg=85"></a><a href="http://dev.site.tld/blog/?pg=86"></a><a href="http://dev.site.tld/blog/?pg=87"></a><a href="http://dev.site.tld/blog/?pg=88"></a><a href="http://dev.site.tld/blog/?pg=89"></a><a href="http://dev.site.tld/blog/?pg=90"></a><a href="http://dev.site.tld/blog/?pg=91"></a><a href="http://dev.site.tld/blog/?pg=92"></a><a href="http://dev.site.tld/blog/?pg=93"></a><a href="http://dev.site.tld/blog/?pg=94"></a><a href="http://dev.site.tld/blog/?pg=95"></a><a href="http://dev.site.tld/blog/?pg=96"></a><a href="http://dev.site.tld/blog/?pg=97"></a><a href="http://dev.site.tld/blog/?pg=98"></a><a href="http://dev.site.tld/blog/?pg=99"></a><a href="http://dev.site.tld/blog/?pg=100"></a><a href="http://dev.site.tld/blog/?pg=101"></a><a href="http://dev.site.tld/blog/?pg=102"></a><a href="http://dev.site.tld/blog/?pg=103"></a><a href="http://dev.site.tld/blog/?pg=104"></a><a href="http://dev.site.tld/blog/?pg=105"></a><a href="http://dev.site.tld/blog/?pg=106"></a><a href="http://dev.site.tld/blog/?pg=107"></a><a href="http://dev.site.tld/blog/?pg=108"></a><a href="http://dev.site.tld/blog/?pg=109"></a><a href="http://dev.site.tld/blog/?pg=110"></a><a href="http://dev.site.tld/blog/?pg=111"></a><a href="http://dev.site.tld/blog/?pg=112"></a><a href="http://dev.site.tld/blog/?pg=113"></a><a href="http://dev.site.tld/blog/?pg=114"></a><a href="http://dev.site.tld/blog/?pg=115"></a><a href="http://dev.site.tld/blog/?pg=116"></a><a href="http://dev.site.tld/blog/?pg=117"></a><a href="http://dev.site.tld/blog/?pg=118"></a><a href="http://dev.site.tld/blog/?pg=119"></a><a href="http://dev.site.tld/blog/?pg=120"></a><a href="http://dev.site.tld/blog/?pg=121"></a><a href="http://dev.site.tld/blog/?pg=122"></a><a href="http://dev.site.tld/blog/?pg=123"></a><a href="http://dev.site.tld/blog/?pg=124"></a><a href="http://dev.site.tld/blog/?pg=125"></a><a href="http://dev.site.tld/blog/?pg=126"></a><a href="http://dev.site.tld/blog/?pg=127"></a><a href="http://dev.site.tld/blog/?pg=128"></a><a href="http://dev.site.tld/blog/?pg=129"></a><a href="http://dev.site.tld/blog/?pg=130"></a><a href="http://dev.site.tld/blog/?pg=131"></a><a href="http://dev.site.tld/blog/?pg=132"></a><a href="http://dev.site.tld/blog/?pg=133"></a><a href="http://dev.site.tld/blog/?pg=134"></a><a href="http://dev.site.tld/blog/?pg=135"></a><a href="http://dev.site.tld/blog/?pg=136"></a><a href="http://dev.site.tld/blog/?pg=137"></a><a href="http://dev.site.tld/blog/?pg=138"></a><a href="http://dev.site.tld/blog/?pg=139"></a><a href="http://dev.site.tld/blog/?pg=140"></a><a href="http://dev.site.tld/blog/?pg=141"></a><a href="http://dev.site.tld/blog/?pg=142"></a><a href="http://dev.site.tld/blog/?pg=143"></a><a href="http://dev.site.tld/blog/?pg=144"></a><a href="http://dev.site.tld/blog/?pg=145"></a><a href="http://dev.site.tld/blog/?pg=146"></a><a href="http://dev.site.tld/blog/?pg=147"></a><a href="http://dev.site.tld/blog/?pg=148"></a><a href="http://dev.site.tld/blog/?pg=149"></a><a href="http://dev.site.tld/blog/?pg=150"></a><a href="http://dev.site.tld/blog/?pg=151"></a><a href="http://dev.site.tld/blog/?pg=152"></a><a href="http://dev.site.tld/blog/?pg=153"></a><a href="http://dev.site.tld/blog/?pg=154"></a><a href="http://dev.site.tld/blog/?pg=155"></a><a href="http://dev.site.tld/blog/?pg=156"></a><a href="http://dev.site.tld/blog/?pg=157"></a><a href="http://dev.site.tld/blog/?pg=158"></a><a href="http://dev.site.tld/blog/?pg=159"></a><a href="http://dev.site.tld/blog/?pg=160"></a><a href="http://dev.site.tld/blog/?pg=161"></a><a href="http://dev.site.tld/blog/?pg=162"></a><a href="http://dev.site.tld/blog/?pg=163"></a><a href="http://dev.site.tld/blog/?pg=164"></a><a href="http://dev.site.tld/blog/?pg=165"></a><a href="http://dev.site.tld/blog/?pg=166"></a><a href="http://dev.site.tld/blog/?pg=167"></a><a href="http://dev.site.tld/blog/?pg=168"></a>

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

Offline

#147 2020-02-06 17:35:34

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

Re: Dev news

Try to remove (useless) total from <txp:pages />.

Offline

#148 2020-02-06 19:02:28

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

Re: Dev news

etc wrote #321554:

Try to remove (useless) total from <txp:pages />.

Hi Oleg,
Thanks for the responce. I did, and there is no change on the output.


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

Offline

#149 2020-02-06 19:34:07

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

Re: Dev news

Sorry, my bad. You have to set either pg or valued total attribute:

<txp:pages pg>
...
</txp:pages>

This will reset the navigation parameters inside the block. But if you have only one navbar, you actually don’t need to enclose it in pages, a mere evaluate will suffice to alter the processing order:

<txp:evaluate test="3,7,5">
...
</txp:evaluate>

Offline

#150 2020-02-07 06:40:56

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

Re: Dev news

etc wrote #321556:

Sorry, my bad. You have to set either pg or valued total attribute:

<txp:pages pg>...

This will reset the navigation parameters inside the block. But if you have only one navbar, you actually don’t need to enclose it in pages, a mere evaluate will suffice to alter the processing order:

<txp:evaluate test="3,7,5">...

That corrects it! Working code:

<txp:evaluate test="3,7,5">
    <nav aria-label="<txp:text item="page_nav" />" class="pagination">
        <ul>
        <txp:newer showalways break="li"><span aria-label="Go to previous page">&#x2962;</span></txp:newer>
        <txp:newer shift break="li"><span aria-label="Go to first page"><txp:yield item="page" /></span></txp:newer>
        <txp:newer shift="5-3" limit="1" break="li"><span role="separator" aria-label="More pages">&hellip;</span></txp:newer>
        <txp:pages total shift="2" break="li"><span aria-label="Go to page <txp:yield item="page" />"><txp:yield item="page" /></span></txp:pages>
        <txp:older shift="5-3" limit="1" break="li"><span role="separator" aria-label="More pages">&hellip;</span></txp:older>
        <txp:older shift break="li"><span aria-label="Go to last page"><txp:yield item="page" /></span></txp:older>
        <txp:older showalways break="li"><span aria-label="Go to next page">&#x2964;</span></txp:older>
        </ul>
    </nav>
</txp:evaluate>

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

Offline

#151 2020-02-07 07:21:16

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

Re: Dev news

This pagination example is great. We should do a small series of blog posts after 4.8.0 release demonstrating this one and a handful of other examples of what can be done with Oleg’s superb tag additions. The new tag stuff make my head spin a bit at times (in a good way) and I don’t pretend to know how they all work – but we would all benefit from some real-world examples (especially where they replace plugins that had to be used in the past to achieve the same thing).

Offline

#152 2020-02-07 09:23:53

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

Re: Dev news

Yes, great idea, Phil.


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

#153 2020-02-07 10:37:26

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

Re: Dev news

philwareham wrote #321558:

This pagination example is great. We should do a small series of blog posts after 4.8.0 release demonstrating this one and a handful of other examples of what can be done with Oleg’s superb tag additions. The new tag stuff make my head spin a bit at times (in a good way) and I don’t pretend to know how they all work – but we would all benefit from some real-world examples (especially where they replace plugins that had to be used in the past to achieve the same thing).

I so much agree with you! I’m still confused what test and shift are doing but also, what the series of numbers actually mean.

These tags, basically made etc_pagination obsolete for most cases.


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

Offline

#154 2020-02-07 11:09:28

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

Re: Dev news

colak wrote #321561:

These tags, basically made etc_pagination obsolete for most cases.

Yep. As <txp:images> pretty much wiped out the need for smd_gallery, and shortcodes / the <txp:header> tag eradicated the need for smd_macro and rah_beacon and rah_external_output. And hopefully we’ll be able to get rid of smd_thumbnail soon in favour of a core solution. All this stuff needs showcasing.

I’m still confused what test and shift are doing but also, what the series of numbers actually mean.

Yeah, it’ll need documenting but in an earlier post I asked some questions that were answered and can give insight:

  1. shift inside <txp:newer/older> is an offset from the end. It can either be valueless (meaning subtract one value ‘in’ from the extremity) or a negative number to move ‘in’ that many values from the extremity.
  2. shift can be a positive value, but I’ve yet to see the benefit of doing that as it goes “off the end” of the pagination by default.
  3. shift can represent a ‘width’ +/- either side of the current page (but I don’t know how to get it to behave this way yet).
  4. shift inside <txp:pages> will add/subtract the given value to the page being iterated over.
  5. shift inside <txp:pages total> represents a width +/- either side of the current page.
  6. A valueless total attribute inside <txp:pages> sets it to ‘current page’, allowing shift and <txp:yield> to operate from this page number.
  7. A total attribute with a value given in a <txp:pages> tag acting as a wrapper sets the maximum number of pages for the navigation.
  8. limit on the <txp:pages> tag will curtail the maximum number of pages to the given limit.
  9. Setting a valueless pg attribute will cause the <txp:pages> tag to hook into the default Txp paging mechanism in the URL. The total will then be automatically set to the number of pages required to paginate all articles in the current section.
  10. Using pure numbers in a test attribute inside a <txp:evaluate> allows you to target individual items inside its container, to control the order they are processed. Normally, tags inside <txp:evaluate> are executed in order, top to bottom, most deeply nested out. But you can alter this by listing which tags you want to execute. e.g. test="3, 7, 5" will process the third <txp:/> tag, then the seventh, then the fifth, then the rest, in order.

That’s all I know right now and hopefully it’s accurate (but might not be!)

Last edited by Bloke (2020-02-07 11:13:36)


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

#155 2020-02-07 11:53:09

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

Re: Dev news

I’m still tweaking it, and your feedback gives new ideas, for example for negative total shift.

What looks settled at this moment? Say, we have 20 pages and the current one is the 3rd.

Number of pages:

<txp:pages total /> outputs 20
<txp:newer total /> outputs 2
<txp:older total /> outputs 17

Links:

<txp:pages shift="-3,-2,-1,0,1,2,3"  /> iterates over pages 1...6 (3 + shift)
<txp:newer shift="3,2,1" /> iterates over pages 1,2 (3 - shift)
<txp:older shift="1,2,3" /> iterates over pages 4,5,6 (3 + shift)
<txp:newer shift="-1,-2,-3" /> iterates over pages 1,2,2 (1 - shift - 1, needs a fix)
<txp:older shift="-3,-2,-1" /> iterates over pages 18,19,20 (20 + shift + 1)

<txp:pages shift /> is not yet set, but could point to pages 1 and 20
<txp:newer shift /> points to page 1
<txp:older shift /> points to page 20

<txp:pages total shift /> iterates over pages 1...20
<txp:newer total shift /> iterates over pages 1...2
<txp:older total shift /> iterates over pages 4...20

<txp:pages total shift="3" /> iterates over pages 1...7 to produce 2*shift + 1 links
<txp:newer total shift="3" /> iterates over pages 1,2
<txp:older total shift="3" /> iterates over pages 4...7.

Negative total shift yet to consider.

Offline

#156 2020-02-07 14:07:56

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

Re: Dev news

THanks to both! This makes absolute sense now. If you do not mind me asking another question in order to fully clarify things in my head.

In this example Oleg starts with <txp:pages total="200" evaluate="3,7,5"> which it did not work but with his recommendation <txp:evaluate test="3,7,5"> worked just fine.

In the new article list pagination system of tags, are there any best practices recommendations on when we should be using pages and when to use other tags?


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