Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[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
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
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
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
Offline
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