Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-11-24 15:40:29

pexman
Member
Registered: 2016-02-27
Posts: 61

pagination on a choiced group of sites

Hy, you know the pagination-feature. All sites of a section are connected and you can click on forward, or back to see the next site or the last. I have make my hole sites navigation very simple, on the right complementary-side you see all articles of this section as excerpt-text. So you can jump directly to a site, without paging. But, if you has jumped into the page, the paginator don`t has a function. I would like, that you can jump on a site, and from there paging the next, or last site.
Can you help me with an idea, how I can script this?

Offline

#2 2020-11-24 16:58:05

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: pagination on a choiced group of sites

Can we have a link?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2020-11-24 17:11:42

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

Re: pagination on a choiced group of sites

There are two kinds of standard pagination built in to Textpattern:

  • link_to_next and link_to_prev tags for doing next article / previous article (with the titles if desired) at the bottom of each article/page.
  • newer and older tags for showing the next newer or older items in a list of articles, e.g. if you show 5 article excerpts at a time, it’ll show you a pagination for the next 5 newer/older items.

You can see these in examples in the default template here and here (GitHub)

If you need more complex pagination, like numbered pagination, there’s the etc_pagination plugin and also a more complex built-in method detailed here on this forum.

Does that help?


TXP Builders – finely-crafted code, design and txp

Offline

#4 2020-11-24 17:19:47

pexman
Member
Registered: 2016-02-27
Posts: 61

Re: pagination on a choiced group of sites

Thank you for your interest.
if you go on https://arteurope.de/gallery/ and scroll down, you will see the button “weiter” in red. Click and go to the next site “Open Pentagon”.

On the right side you will see a sideboard with all articles belonging to this section. You can click here direct on the page “Open Pentagon” but then you have not the possibility to paging about the next.

Is there a way to activate the paginator?

Last edited by pexman (2020-11-24 17:22:20)

Offline

#5 2020-11-24 17:38:11

pexman
Member
Registered: 2016-02-27
Posts: 61

Re: pagination on a choiced group of sites

Hi Jacob, thanks for the answer.
It is not the problem, that it dosn`t work, but not from all “positions”. If I navigate threw the sidebar, the paginator doesn`t work. The exzerpts-articles in the sidebar are using the same template.

Offline

#6 2020-11-24 17:42:42

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

Re: pagination on a choiced group of sites

Yes, when you click on the article title in the sidebar, it takes you to the article at https://arteurope.de/gallery/OpenPentagon.

As that is a single article (so-called individual_article context), you need the tags “link_to_next” and “link_to_prev”.

I’m guessing that the inactive “weiter” and “zurück” links are appearing on individual pages, so you need to wrap the txp:newer and txp:older tags in <txp:if_article_list> … </txp:if_article_list>.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2020-11-24 21:02:28

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

Re: pagination on a choiced group of sites

Creating pagination links on individual article pages is not straightforward, but should be doable. The main difficulty is to find the current article page number. The easiest solution would be to append it to article links generated on list pages (e.g. arteurope.de/gallery/OpenPentagon?pg=2), but this looks dirty. Another solution is to generate (on individual pages) an IDs list and seek the current article position in this list:

<txp:variable name="artids" trim>
    <txp:article_custom limit="999" break=","><txp:article_id /></txp:article_custom>
</txp:variable>

<txp:php>
    global $thisarticle;
    $id = $thisarticle['thisid'];
    $artids = do_list(parse('<txp:variable name="artids" />'));
    if(($current = array_search($id, $artids)) !== false)
        echo 'Page '.ceil(($current + 1)/10).' of '.ceil(count($artids)/10);
</txp:php>

You can extract the “current” page number and the total number of pages from this code and plug it into <txp:pages />.

Offline

#8 2020-11-24 22:45:54

pexman
Member
Registered: 2016-02-27
Posts: 61

Re: pagination on a choiced group of sites

Realy nice, two competent answers, but sorry etc, I don`t understand your code.
I fill the variable named artid with the article_id of all custom articles, then the php script makes the variable thisarticle, may be it iterate about all the found ( $id = $thisarticle[‘thisid’]; ), and then, if there is any id, then… ??? here I`m totaly out.

Someday I’ll understand that.

Your idea, jakob, is more in my level. <txp:if_article_list> wasn`t necessary but <txp:if_individual_article> does the work. Thank you both for time and innovation.

Offline

#9 2020-11-25 09:10:17

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

Re: pagination on a choiced group of sites

pexman wrote #327030:

sorry etc, I don`t understand your code.

You mostly do, and I can explain further, but there is a difference between my snippet and jacob’s one. Mine can be adapted to create links to prev/next list of articles. This of jacob suits for links to prev/next article.

Offline

Board footer

Powered by FluxBB