Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-01-26 04:45:59

Myusername
Member
Registered: 2019-12-12
Posts: 44

Pagination in article_custom without plugins?

I’m trying to create a area of articles sorted by keywords. Something like:

<txp:article_custom keywords="Textpattern, Key, Words" limit="5">
  // something here //
</txp:article_custom>

But I need a way to have pagination in this article_custom. Searching, I found many people using the etc_pagination plugin. Anyway, I would like to know there is some known way of doing this with textpattern tags, even if it doesn’t work perfectly. Your help would be appreciated.

Offline

#2 2020-01-26 19:00:15

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

Re: Pagination in article_custom without plugins?

I have added two attributes to <txp:newer/older /> tags that make the construction easier:

<txp:variable name="pages" value='<txp:article_custom keywords="Textpattern, Key, Words" pageby="5" pgonly />' />

<txp:newer pg="page" total='<txp:variable name="pages" />'>
    Page <txp:yield item="page" />
</txp:newer>
<txp:older pg="page" total='<txp:variable name="pages" />'>
    Page <txp:yield item="page" />
</txp:older>

This will generate ‘newer/older’ links with page=n±1 parameter appended. To plug page value into <txp:article_custom /> use

<txp:variable name="offset" escape="trim">
    <txp:evaluate query='(<txp:page_url type="page" escape="number" default="1" /> - 1)*5' />
</txp:variable>

<txp:article_custom keywords="Textpattern, Key, Words" limit="5" offset='<txp:variable name="offset" />'>
    // something here //
</txp:article_custom>

Hope we will nail it for 4.8 release, please test. Just note that you can filter <txp:article /> by keywords too.

Offline

Board footer

Powered by FluxBB