Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2025-10-24 07:16:33

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,499
Website

‘showalways’ for txp:newer (and txp:older) not working?

Usage: <txp:newer showalways>some text</txp:newer><txp:older showalways>different text</txp:older>, (preceded by an article list with limit=“10”).
Expected: output the “xxx text” string always even if no newer/older page (list) exists (per docs, unless I am misunderstanding the usage completely).
Actual result: no output when no newer/older page (list) exists. showalways or showalways="1" always show blank.

Textpattern 4.9-dev latest, context is a <txp:pages> block, but standalone usage on a page template returns same results; PHP 8.3 / 8.4.

(I cannot test on TXP 4.8.8 atm).


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#2 2025-10-24 08:43:42

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

Re: ‘showalways’ for txp:newer (and txp:older) not working?

The construction has changed in 4.9:

<txp:older>
    link
<txp:else /><!-- showalways part -->
    text
</txp:older>

This is more flexible, but less intuitive, so I will try to combine it with the pre-4.9 functionality.

Offline

#3 2025-10-24 08:56:37

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,499
Website

Re: ‘showalways’ for txp:newer (and txp:older) not working?

etc wrote #340996:

The construction has changed in 4.9:

<txp:older>...

This is more flexible, but less intuitive, so I will try to combine it with the pre-4.9 functionality.

Oh. That does indeed offer some more flexibility, e.g accessibility wise. Now I’ll need to check to update my txp:pages block (which is basically the docs example). So It would probably be nice to if there is a way to get old and new construct.

<txp:newer rel='prev'>
  link - previous page
<txp:else />
  no previous pages
</txp:newer>

Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#4 2025-10-24 10:29:59

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

Re: ‘showalways’ for txp:newer (and txp:older) not working?

Both constructs should be working now, with an extra flexibility added by showalways:

<txp:newer rel='prev' showalways='...'>
  link - previous page
<txp:else />
  no previous pages
</txp:newer>

Depending on showalways value (which can be pulled from some variable), it will output the true or the false part when no newer page exists.

Offline

#5 2025-10-24 11:00:36

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,499
Website

Re: ‘showalways’ for txp:newer (and txp:older) not working?

Sounds great, with lots of flexibility for the first/last item in the pagination.

Thank you 😊.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#6 2025-10-24 15:14:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,024
Website GitHub

Re: ‘showalways’ for txp:newer (and txp:older) not working?

etc wrote #340999:

Both constructs should be working now, with an extra flexibility added by showalways

Oh that’s so sweet. Thank you.

You know what my next question is going to be regarding showalways in other tags now… 😁


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

Online

#7 Today 03:14:07

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,499
Website

Re: ‘showalways’ for txp:newer (and txp:older) not working?

This works nice on a standalone usage of the <txp:newer /> and <txp:older />@ tags. But when combined inside a <txp:pages> block, I see odd results. For reference, I use basically the code given on the docs page (or here, forum page). The issue is on the top-level first/last instance of the tags.

Current code:

<txp:pages pg link="" showalways="2">
  <nav class="pagination <txp:if_section>article-paging</txp:if_section>" aria-label="Page navigation">
    <span>Pages:</span>
    <txp:newer showalways><a rel="prev" href="<txp:yield item="url" />" title="Go to previous page" aria-label="Go to previous page">Previous</a><txp:else /><span aria-label="You reached the first page" class="n-o disabled">Previous</span></txp:newer>
    <ul class="list-pagination">
      <txp:newer[2] shift><li><a href="<txp:yield item="url" />" title="Go to page <txp:yield item="page" />" aria-label="Go to page <txp:yield item="page" />"><txp:yield item="page" /></a></li></txp:newer>
      <txp:newer shift="-2"><li role="separator" title="More pages" aria-label="More pages">…</li></txp:newer>
      <txp:newer[3] total shift="2"><li><a href="<txp:yield item="url" />" title="Go to page <txp:yield item="page" />" aria-label="Go to page <txp:yield item="page" />"><txp:yield item="page" /></a></li></txp:newer>
      <txp:pages[1]><li class="current-page"><b title="Current page" aria-current="page"><txp:yield item="page" /></b></li></txp:pages>
      <txp:older[3] total shift="2"><li><a href="<txp:yield item="url" />" title="Go to page <txp:yield item="page" />" aria-label="Go to page <txp:yield item="page" />"><txp:yield item="page" /></a></li></txp:older>
      <txp:older shift="-2"><li role="separator" title="More pages" aria-label="More pages">…</li></txp:older>
      <txp:older[2] shift><li><a href="<txp:yield item="url" />" title="Go to page <txp:yield item="page" /> (last page)" aria-label="Go to page <txp:yield item="page" /> (last page)"><txp:yield item="page" /></a></li></txp:older>
    </ul>
    <txp:older showalways><a rel="next" href="<txp:yield item="url" />" title="Go to next page" aria-label="Go to next page">Next</a><txp:else /><span aria-label="You reached the last page" class="n-o disabled">Next</span></txp:older>
  </nav>
</txp:pages>

Issue – two variations

  1. with using the showalways attribute, the first page and the last page show the “Previous” / ”Next” strings as links. I would expect, given the code, to make use of the fallback code.
  2. omitting the showalways attribute on those two instances: the “Previous” / ”Next” strings only appear on the first and last page. If you go to e.g page 3 of a list, those two are not inserted.

What I would like, ideally, is display the “Previous” / ”Next” strings, as links, except when the user reaches the first or last page of the list, the I would like either: do no show anything (no “Next” on that page), or show the text string but using a fallback code

An example set of list pages – emps.l-c-n.com/test-4/ (a list of six pages of random generated articles). or demonstration purposes, the showalways attribute is omitted on the “Previous” (newer) link, to the left of “1” the “Preview” link should appear but doesn’t. For comparison, I’ve included a standalone sample as well.

The way it worked with TXP 4.8, see the Textpattern blog pages. This is probably what most people expect to see.

The reason I am eventually interested in showing the “Previous” / ”Next” strings as plain text wrapped in some markup on first/last page is for accessibility reason, although the way it used to work with TXP 4.8 is already quite good.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

Board footer

Powered by FluxBB