Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Link to next article based on custom field
Hey guys, I wonder if some one can help.
I am trying to link to the next article based on the custom field entry. I thought some thing like this would work:
<txp:link_to_next YouTubeSeries=“alienisolation” ><txp:next_title /></txp:link_to_next>
I’m using glz_custom_fields to have more customer fields and YouTubeSeries is the name of the field. I basically only want to show the next article that has the same YouTubeSeries entry.
Any help would be greatly appreciated!
Offline
Re: Link to next article based on custom field
There currently seems to be no <txp:tag />
way, though the core code looks as if it was planned. Plugins (smd/etc_query, etc_search, ...
) could do it, but <txp:php>
solution is rather short:
<txp:variable name="previd"><txp:php>
global $thisarticle;
$prevart = getNeighbour(
'from_unixtime('.doSlash($thisarticle['posted']).')',
$thisarticle['section'],
'<',
array('sortby'=>'Posted', 'sortdir'=>'desc', 'youtubeseries'=>$thisarticle['youtubeseries']) + filterAtts(),
'cooked');
echo empty($prevart['ID']) ? '' : $prevart['ID'];
</txp:php></txp:variable>
<txp:if_variable name="previd" value=""><txp:else />
<txp:article_custom form="your_link_to_prev_form" id='<txp:variable name="previd" />' />
</txp:if_variable>
Replace '<'
with '>'
for the next
link, if it works at all (not tested with glz_custom_fields
).
Edit: lowercase cf name and if_variable
test.
Last edited by etc (2015-02-06 21:32:32)
Offline
Re: Link to next article based on custom field
Thank you for the reply. Unfortunately it does not work. Is there any way to achieve a similar function using keywords?
Thank you in advance, I really appreciate the help.
Offline
Re: Link to next article based on custom field
I’m not sure if this will work
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Link to next article based on custom field
SPKuja wrote #287983:
Thank you for the reply. Unfortunately it does not work. Is there any way to achieve a similar function using keywords?
Works for me if cf name is lowercase: youtubeseries
. Will probably work with keywords too (untested).
Offline
Re: Link to next article based on custom field
etc wrote #287987:
Works for me if cf name is lowercase:
youtubeseries
. Will probably work with keywords too (untested).
Okay, I altered it to use lower case letters but when it gets to the 1st article it then shows all of the most recently posted articles. Is there any way to hide it once it is at the first article?
Offline
Re: Link to next article based on custom field
SPKuja wrote #288076:
Okay, I altered it to use lower case letters but when it gets to the 1st article it then shows all of the most recently posted articles. Is there any way to hide it once it is at the first article?
Yes, sorry. Replace echo $prevart['ID'];
with
echo empty($prevart['ID']) ? '' : $prevart['ID'];
and call
<txp:if_variable name="previd" value=""><txp:else />
<txp:article_custom form="your_link_to_prev_form" id='<txp:variable name="previd" />' />
</txp:if_variable>
Last edited by etc (2015-02-06 21:32:47)
Offline
Re: Link to next article based on custom field
Sorry for the late reply. I still cannot get this to work. Is there any other method that may work? I can always do it based on category but I cannot seem to find any way to do that either. It doesn’t have to be by custom field, I just need a method to show the next article in the series, not every single article.
Offline
Re: Link to next article based on custom field
SPKuja wrote #288547:
I can always do it based on category but I cannot seem to find any way to do that either.
Could smd_horizon help at all? That can navigate between categories.
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
Re: Link to next article based on custom field
Perfect! It works exactly as I need it too! Great plugin, thanks!
Offline