Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-06-01 20:07:54

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

How to troubleshoot missing link_to_next and link_to_prev?

Hi!

I have a form that conditionally displays next and previous links for articles in a given section. The form is called from within the article form, and shows up only in individual article context. It works great in all sections but one.

For one section, I noticed it is displaying “Next” links only, no “Previous” links at all. One can navigate back to the article list and click on previous articles, but the previous articles aren’t being detected on the individual article pages.

I added this to the top of my page template (before anything else) to see what’s going on:

<pre>
next_id:      "<txp:php>global $pretext; echo $pretext['next_id'];</txp:php>",
link_to_next: "<txp:link_to_next/>",
prev_id:      "<txp:php>global $pretext; echo $pretext['prev_id'];</txp:php>",
link_to_prev: "<txp:link_to_prev/>"
</pre>

And Textpattern has no idea that there are previous “live” articles in the section:

next_id:      "",
link_to_next: "http://my.tld/news/my-article-title",
prev_id:      "",
link_to_prev: ""

Do you have any guess how I might begin troubleshooting this? Any guesses what might clobber the link_to_prev URL before the beginning of the template?

The article tag on the individual article template is as simple as can be: <txp:article/>

Offline

#2 2016-06-02 07:44:33

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

Re: How to troubleshoot missing link_to_next and link_to_prev?

johnstephens wrote #299396:

Do you have any guess how I might begin troubleshooting this? Any guesses what might clobber the link_to_prev URL before the beginning of the template?

The article tag on the individual article template is as simple as can be: <txp:article/>

What is txp version and the sort attribute of <txp:article />? Anyway, it’s not $pretext but $thisarticle that stores next/prev links.

Offline

#3 2016-06-02 14:52:50

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: How to troubleshoot missing link_to_next and link_to_prev?

Thank you, Etc!

The article tag is exactly as I posted it above: no sort attribute, no form (it’s using the default form).

Do you know where I can find updated documentation on Textpattern’s global variables? I’m going by the record in Textpattern Solutions, 476–489, because of the ease of reference. But that text is 9 years old.

Offline

#4 2016-06-02 15:26:47

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: How to troubleshoot missing link_to_next and link_to_prev?

I think I figured out the problem, but still haven’t found a solution.

We use an expiry date on all articles in this section except the most recent. The most recent article will display a “previous” link to the previous article, even if it’s expired, but the expired articles only display “next” links, whether the next article is expired or not. Textpattern does not detect a previous link if both the current article and the previous one have a past expiry date.

I suppose I can file a bug report on Github (supposing the inconsistent detection of “next” and “previous” links with expired articles isn’t intentional), but is there any possible workaround?

Offline

#5 2016-06-02 15:42:12

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

Re: How to troubleshoot missing link_to_next and link_to_prev?

Does the behaviour change if you alter the Pref setting Publish expired articles?

EDIT: Mind you, that’ll probably throw up a whole slew of other issues that you’ll need to alter in your template to prevent articles popping up where yo don’t want them.


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

#6 2016-06-02 15:50:19

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: How to troubleshoot missing link_to_next and link_to_prev?

Hey, Stef!

My preference to “Publish expired articles?” was already set to yes. Setting it to “no” gives the same behavior for unexpired articles, it just gets rid of the expired ones in the sections article list context.

Does that make sense?

Offline

#7 2016-06-02 16:00:05

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

Re: How to troubleshoot missing link_to_next and link_to_prev?

johnstephens wrote #299425:

“Publish expired articles?” was already set to yes.

Nuts. Was a long shot. I’ll have to try and simulate your setup on a test install and figure out what’s going on. Will see what I can do tonight.


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

#8 2016-06-02 21:18:50

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: How to troubleshoot missing link_to_next and link_to_prev?

I thought I’d make it easier for you by creating a fresh install using Txp 4.5.7, and doing just enough configuration to duplicate the problem (using the default archive template), then send you a MySQL dump of the data—maybe even a Github repo with the Vagrant box.

I thought all I would need to do is set “Publish expired articles?” to yes, and then add some articles in the articles section, and make all of them expired except for the newest one.

That did not reproduce the problem, though. Textpattern was still able to detect adjacent articles using the link_to_next and link_to_prev tags already present in the archive template.

So, I copied all the adjacent article navigation from the archive template on the test install to my site where I’m having the problem—it wasn’t so different from what I had, but just in case—and it behaves the same way my own code does. In other words, it doesn’t work. Hmmm.

Do you know of any common plugins that could clobber the previous and next values for expired articles? Obviously the site I’m working on is more complex than a basic fresh installation, but I’m puzzled.

Offline

#9 2016-06-02 21:29:23

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: How to troubleshoot missing link_to_next and link_to_prev?

Is there anything I could dmp() that might help identify what is happening?

Offline

#10 2016-06-02 21:45:24

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

Re: How to troubleshoot missing link_to_next and link_to_prev?

Could you post your Form that has the conditional next/prev tags in it please? I can copy it to my test site then. Thanks.


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

#11 2016-06-02 21:54:49

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: How to troubleshoot missing link_to_next and link_to_prev?

Here it is:

<txp:variable name="prev_url"><txp:link_to_prev/></txp:variable>

<txp:variable name="next_url"><txp:link_to_next/></txp:variable>

<txp:if_variable name="prev_url" value="">

  <txp:variable name="has_next_and_prev" value="0"/>

  <txp:else/>

  <txp:if_variable name="next_url" value="">

    <txp:variable name="has_next_and_prev" value="0"/>

    <txp:else/>

    <txp:variable name="has_next_and_prev" value="1"/>

  </txp:if_variable>

</txp:if_variable>





<nav class='adjacent-article-nav'>

  <txp:link_to_prev>&lsaquo; Previous <txp:yield/></txp:link_to_prev>

  <txp:if_variable name="has_next_and_prev" value="1">
    |
  </txp:if_variable>

  <txp:link_to_next>Next <txp:yield/> &rsaquo;</txp:link_to_next>

</nav> <!-- eo .adjacent-article-nav -->

Offline

#12 2016-06-02 22:05:20

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: How to troubleshoot missing link_to_next and link_to_prev?

I found something else weird. Maybe it’s normal, and I just never noticed it before.

When I add <pre><txp:php>dmp($thisarticle);</txp:php></pre> to the very top of my Page template, before anything else, and load one of the “expired” article pages, it doesn’t spit out any of the following key-value pairs:

  • next_id
  • next_title
  • next_utitle
  • next_posted
  • prev_id
  • prev_title
  • prev_utitle
  • prev_posted

However, when I put the same dmp() function just above the txp:article tag, I get all those keys, even though the “prev_” items are inexplicably empty.

  'next_id' => '961',
  'next_title' => 'My article title',
  'next_utitle' => 'my-article-title',
  'next_posted' => '1460670088',
  'prev_id' => '',
  'prev_title' => '',
  'prev_utitle' => '',
  'prev_posted' => '',

Last edited by johnstephens (2016-06-02 22:06:46)

Offline

Board footer

Powered by FluxBB