Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-12-05 07:16:03

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

[Solved] The comments tag and pagination

The <txp:comments /> tag accepts a limit attribute (and works well), but how can we paginate through the others comments? 🤔

Last edited by Pat64 (2023-12-06 05:20:17)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#2 2023-12-05 10:47:34

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

Re: [Solved] The comments tag and pagination

Hi Patrick,

That’s not straightforward, but easy enough:

<!-- setting limit, offset and numpages -->
<txp:variable name="limpg" value="2" />
<txp:variable name="offpg"><txp:evaluate query='<txp:variable name="limpg" />*(<txp:page_url type="pgc" default="1" escape="integer" />-1)' /></txp:variable>
<txp:variable name="numpg"><txp:evaluate query='ceiling(<txp:comments_count /> div <txp:variable name="limpg" />)' /></txp:variable>

<!-- pagination bar, with pgc as page parameter -->
<txp:pages pg="pgc" total='<txp:variable name="numpg" />'>
    <txp:pages shift wraptag="nav" break="|"><txp:yield item="page" /></txp:pages>
</txp:pages>

<!-- output comments -->
<txp:comments limit='<txp:variable name="limpg" />' offset='<txp:variable name="offpg" />' />

Offline

#3 2023-12-05 11:21:56

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: [Solved] The comments tag and pagination

🥇

Perfect. Thank you so much.


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#4 2023-12-05 12:33:58

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

Re: [Solved] The comments tag and pagination

What an amazing hack! Though I do sense an opportunity here… :)


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

#5 2023-12-05 16:59:27

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

Re: [Solved] The comments tag and pagination

Bloke wrote #336020:

I do sense an opportunity here… :)

Many! What about

<txp:comments limit="10" offset="pgc" />

paginating by pgc URL parameter? I do not dare touching <txp:pages />, it’s already over-bloated.

Offline

#6 2023-12-05 17:12:41

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

Re: [Solved] The comments tag and pagination

That would work!


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