Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

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

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

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

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

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.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

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

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

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.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

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

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

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.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

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

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

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

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.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

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

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

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

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.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

Board footer

Powered by FluxBB