Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

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

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

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

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
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: 9,785
Website

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

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

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

Offline

#157 2020-02-07 14:22:09

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

Re: Dev news

colak wrote #321564:

In this example Oleg starts with <txp:pages total="200" evaluate="3,7,5"> which it did not work

It did, what did not work was <txp:pages total evaluate="3,7,5"> for the reason explained above: <txp:pages total /> is supposed to output the number of pages.

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?

They are still moving, but the global rule is: use <txp:pages /> as pagination container when you need to reset pagination parameters pg and total, for example when creating custom pagination bars.

Offline

#158 2020-02-07 14:44:59

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

Re: Dev news

etc wrote #321565:

They are still moving, but the global rule is: use <txp:pages /> as pagination container when you need to reset pagination parameters pg and total, for example when creating custom pagination bars.

Whoops, I did not want it to sound that I was pointing fingers. Apologies. I’m just trying to understand the concepts in order to be able to help others. This makes sense now. Thanks to both.


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.

Offline

#159 2020-02-07 14:49:38

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

Re: Dev news

colak wrote #321566:

Apologies. I’m just trying to understand the concepts in order to be able to help others.

No worries, I’m just trying to explain how it works, partly to myself.

Offline

#160 2020-02-10 17:11:53

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,330
Website

Re: Dev news

I updated my Complex Pagination using all the discussion ideas here.

It now only requires one block of code and no plugins.

Offline

Board footer

Powered by FluxBB