Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-12-25 07:28:26

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

Next and Prev article Question

Hi

I try to make a next and prev article navigation on an individual article context but cant get what i want, i need the next and prev to be limited to a particular category but link_to_next and link_to_prev havent that option!

Can someone give me a hint how to that ? the sole solution that came to my mind is to rely on php code creating an array of article id and then look to a next and prev there.

Thanks.

Offline

#2 2018-12-25 07:55:06

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

Re: Next and Prev article Question

I’m wondering if etc_pagination would do the job.


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 2018-12-25 08:48:04

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

Re: Next and Prev article Question

Hi Yianis,

I am not sure it can handle the individual article context problem.

Thanks.

Offline

#4 2018-12-25 09:21:45

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

Re: Next and Prev article Question

Hi Dragondz,

A mod from the first example looks like it could work.

<txp:if_individual_article>
    <txp:etc_pagination pgcounter="page" pages='<txp:etc_numpages section="news" category="your_category" />' />
</txp:if_individual_article>

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

Offline

#5 2018-12-25 11:16:22

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

Re: Next and Prev article Question

In 4.7.2 you can try to add context="c" attribute to <txp:permlink /> in list form and <txp:link_to_next|prev /> in individual article form. It should retain the current category parameter in article links and filter by its value.

Offline

#6 2018-12-25 11:29:03

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

Re: Next and Prev article Question

etc wrote #315720:

In 4.7.2 you can try to add context="c" attribute to <txp:permlink /> in list form and <txp:link_to_next|prev /> in individual article form. It should retain the current category parameter in article links and filter by its value.

There so much to add to the docs!! I’ll be updating that too.


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

Offline

#7 2018-12-25 14:38:46

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

Re: Next and Prev article Question

Hi Oleg thanks for information,

I upgraded to 4.7.2 from 4.7.1 and tryed :

<txp:link_to_prev context="c"/>
<txp:link_to_next context="c"/>

in individual article context but that havent worked, the next and prev link are still pointing to a non categorised article.

Cheers.

Offline

#8 2018-12-25 18:49:37

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

Re: Next and Prev article Question

To enable filtering, you must access this page via an URL containing c parameter, e.g. index.php?id=123&c=mycat. The latter is not a canonical permlink obtained with <txp:permlink />. To construct it, replace <txp:permlink /> with <txp:permlink context="c" /> where appropriated. Then, when you are on mycat category list, all permlinks will have c=mycat appended.

Offline

#9 2018-12-26 07:45:15

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

Re: Next and Prev article Question

Only one word : wouaaaaaouuuuuu!

Unbelievable!

Offline

#10 2019-01-06 16:08:42

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: Next and Prev article Question

There is such a recommendation of the correct pagination

Pagination attributes: link rel=“next” and rel=“prev”

The <txp:newer /> and <txp:newer /> tags inside <head> do not work.

It was possible to launch such a construction:

<head>
....
<txp:if_article_list>
<txp:variable name="prev" value='<txp:newer />' />
<txp:variable name="next" value='<txp:older />' />
<txp:if_variable name="prev" value="">
<txp:else />
<link rel="prev" href="<txp:newer />">
</txp:if_variable>
<txp:if_variable name="next" value="">
<txp:else />
<link rel="next" href="<txp:older />">
</txp:if_variable>
</txp:if_article_list>
.....
</head>

But it works a bit wrong.

In the middle, everything works as it should:

<head>
....
<link rel="canonical" href="https://domain.dom/section-one/?pg=2">
<link rel="prev" href="https://domain.dom/section-one/">
<link rel="next" href="https://domain.dom/section-one/?pg=3">
....
</head>

But the first and last pages do not work correctly:

First

<head>
....
<link rel="canonical" href="https://domain.dom/section-one/">
<link rel="prev" href="">
<link rel="next" href="https://domain.dom/section-one/?pg=2">
....
</head>

Incorrect mapping <link rel=“prev” href=”“>

Last

<head>
....
<link rel="canonical" href="https://domain.dom/section-one/?pg=8">
<link rel="prev" href="https://domain.dom/section-one/?pg=7">
<link rel="next" href="">
....
</head>

Incorrect mapping <link rel=“next” href=”“> .

How to do it right?

Last edited by singaz (2019-01-06 16:15:16)


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#11 2019-01-06 17:38:55

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

Re: Next and Prev article Question

Your code should actually work but tested it and indeed it does not as the variables seem to be throwing false positives. I also tried the more efficient.

<head>
....
<txp:if_article_list>
<txp:variable name="prev" value='<txp:newer />' />
<txp:variable name="next" value='<txp:older />' />
<txp:if_variable name="prev" value="">
<txp:else />
<link rel="prev" href="<txp:variable name="next" />">
</txp:if_variable>
<txp:if_variable name="next" value="">
<txp:else />
<link rel="next" href="<txp:variable name="prev" />">
</txp:if_variable>
</txp:if_article_list>
.....
</head>

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

Offline

#12 2019-01-06 17:44:42

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

Re: Next and Prev article Question

Did you try?

<txp:if_article_list>
<txp:evaluate test="older, newer">
<link rel="prev" href="<txp:older />">
<link rel="next" href="<txp:newer />">
</txp:evaluate>
</txp:if_article_list>

> Edit: This does not seem to be work either:( There seems to be a bug somewhere in the older newer tags which should be reported in the Core development forum.

> Edit 2. Reported it on github.

Last edited by colak (2019-01-06 19:53:34)


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

Offline

Board footer

Powered by FluxBB