Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-02-16 07:55:04

joanlafulla_Almas
Member
Registered: 2011-02-25
Posts: 13

Pagination in "article_custom"

Hi,
Is there a working way to paginate an <article_custom> results?

I have found this tip page:
https://txptips.com/enable-pagination-with-article_custom-article-listings

I can’t find the required plugins: adi_gps, adi_calc and rah_repeat

Offline

#2 2024-02-16 08:38:51

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Re: Pagination in "article_custom"

Hi

You could use etc_pagination for that.

Cheers.

Offline

#3 2024-02-16 09:06:01

joanlafulla_Almas
Member
Registered: 2011-02-25
Posts: 13

Re: Pagination in "article_custom"

Dragondz wrote #336671:

Hi

You could use etc_pagination for that.

Cheers.

Yes, thanks. I’m trying to use etc_pagination, but it doesn’t work for me.
I have this article_custom to show a list of articles with match a certain category in URL (“URL: ../index.php?s=category&c=noticia”):

<txp:article_custom category=’<txp:category />’ limit=“2”>

And the part of etc_pagination:
<txp:etc_pagination range=“2” prev=“Previous” next=“Next” wraptag=“ul” break=“li” />

The list is OK, I can see 2 articles with the category “noticia”. But the part of the pagination doesn’t work.

Offline

#4 2024-02-16 09:15:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: Pagination in "article_custom"

I think there’s a post on the forum for that using textpattern’s in-built tags. I’ll post back if I can find it.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2024-02-16 09:15:23

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

Re: Pagination in "article_custom"

<txp:article_custom> has been able to natively paginate from Textpattern 4.8.5 onward (though the docs are sadly out of date on this matter). If you’re using a recent version, you should be able to leverage the pageby attribute to trigger this behaviour, then use the txp:pages tag to output a navigable pagination.

EDIT: jakob was faster :-) and I hope he can find the post, because I didn’t turn it up in a cursory search.

Last edited by Bloke (2024-02-16 09:16:29)


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

#6 2024-02-16 09:32:42

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: Pagination in "article_custom"

jakob wrote #336676:

I think there’s a post on the forum for that using textpattern’s in-built tags. I’ll post back if I can find it.

This is not quite the post I was thinking of, but here are some that you may be able to crop ideas from:

(I’m sure Michael posted a full solution somewhere, but just can’t lay my hands on it) That one was out of date, but Phil posted a variant that is used on the textpattern homepage (here). I think you just need to feed it with the total number of pages from your article_custom tag as discussed in Oleg’s other post. Maybe Oleg can chime in with an example.

Note to self: must finally try this out properly myself.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2024-02-16 10:30:01

joanlafulla_Almas
Member
Registered: 2011-02-25
Posts: 13

Re: Pagination in "article_custom"

jakob wrote #336679:

This is not quite the post I was thinking of, but here are some that you may be able to crop ideas from:

(I’m sure Michael posted a full solution somewhere, but just can’t lay my hands on it) That one was out of date, but Phil posted a variant that is used on the textpattern homepage (here). I think you just need to feed it with the total number of pages from your article_custom tag as discussed in Oleg’s other post. Maybe Oleg can chime in with an example.

Note to self: must finally try this out properly myself.

I tried the article_custom example but I think I do something bad.

This is my alticle_custom:

<txp:article_custom category=’<txp:category />’ limit=“2”>

And this is the pagination:

<txp:page_url context=“c” s=’<txp:category />’>
<txp:pages total=’<txp:article_custom category pgonly/>’ />
<txp:pages total shift link=”“ break=“loc”>
<txp:yield item=“url” />
</txp:pages>
</txp:page_url>

The result are two links:
http://localhost:8888/index.php?c=noticia&s=category
http://localhost:8888/index.php?c=noticia&s=category&pg=2

But the second URL doesn’t show the rest of articles (we have published 5 articles, and a limit of two in the article_custom.

Offline

#8 2024-02-16 11:18:04

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

Re: Pagination in "article_custom"

As I get it, <txp:page_url /> in your example should complain about unknown s attribute (nice use otherwise), but let it be. Assuming the pagination links are ok, to output the corresponding articles you need to add offset attribute to <txp:article_custom />. I have also added pageby, to avoid the second call:

<txp:article_custom limit="2" offset pageby>
<txp:title />
</txp:article_custom>

And this is the pagination:

<txp:page_url context="c" s='<txp:category />'>
<txp:pages total shift link="" break="loc">
<txp:yield item="url" />
</txp:pages>
</txp:page_url>

Please test.

Offline

#9 2024-02-16 11:37:35

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

Re: Pagination in "article_custom"

For the full pagination bar, this works for me, but also adding offset to respond to the pagination requests:

<article::custom category='<txp:category />' limit="2" offset pageby />

<txp:page_url context="c">
  <txp:evaluate query='<txp:pages total /> > 1'>
    <txp:pages evaluate="5,2,8,4,6">
        <nav class="paginator" aria-label="Blog navigation">
            Pages:
            <txp:newer showalways link=""><a rel="prev" href="<txp:yield item="url" />" title="Go to previous page" aria-label="Go to previous page">Previous</a></txp:newer>
            <ul class="pagination">
                <txp:newer shift link=""><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" link=""><li role="separator" title="More pages" aria-label="More pages">…</li></txp:newer>
                <txp:newer total shift="2" link=""><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="0" link=""><li class="current"><b title="Current page" aria-current="page"><txp:yield item="page" /></b></li></txp:newer>
                <txp:older total shift="2" link=""><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" link=""><li role="separator" title="More pages" aria-label="More pages">…</li></txp:older>
                <txp:older shift link=""><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 link=""><a rel="next" href="<txp:yield item="url" />" title="Go to next page" aria-label="Go to next page">Next</a></txp:older>
        </nav>
    </txp:pages>
  </txp:evaluate>
</txp:page_url>

EDIT: Oleg was waaay faster :)

Last edited by Bloke (2024-02-16 11:40:45)


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

#10 2024-02-16 12:38:24

joanlafulla_Almas
Member
Registered: 2011-02-25
Posts: 13

Re: Pagination in "article_custom"

Wooow! I think it works!

Thank you very much. You have a friend in me :-)

If you want to know my site (in textpattern):
https://darkblobcine.com/

I have to make the changes in the pagination yet (I have tried it locally).

Offline

#11 2024-02-16 12:52:32

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

Re: Pagination in "article_custom"

Glad you got it going. That’s a sweet-looking site! Very impressive.


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

Board footer

Powered by FluxBB