alexcapes Posted August 4, 2015 Share Posted August 4, 2015 Hi all, I have the following simple code for next/previous links on article pages: <!-- Next article --> <?if($page->next->id) { ?><i class="icon-chevron-left"></i> <a href="<?echo $page->next->url; ?>"> <?=${'previous_'.$countryCode}; ?></a><? } ?> <!-- /Next article --> <!-- Previous article --> <?if($page->prev->id) { ?> <a href="<?echo $page->prev->url; ?>"><?=${'next_'.$countryCode}; ?></a> <i class="icon-chevron-right"></i> <? } ?> <!-- /Previous article --> It all works correctly but there's a certain type of article I need to exclude from the next/previous links (any page that has options field 'content_type' with a value of '6'). I'm trying to figure out a way to get 'next' and 'previous' but if 'content_type' on that page has a value of '6' then skip it. Can anyone help with some clues on how this might be done? I've had a look at using the pagination code as well as looking at grabbing 'siblings' and filtering them but come to a dead end. Thanks! Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 5, 2015 Share Posted August 5, 2015 $list = $page->siblings("content_type!=6"); $list->getPrev($page); $list->getNext($page); 3 Link to comment Share on other sites More sharing options...
alexcapes Posted August 5, 2015 Author Share Posted August 5, 2015 $list = $page->siblings("content_type!=6"); $list->getPrev($page); $list->getNext($page); Wonderfully simple solution - thank you LostKobrakai! For anyone interested this was my final code - all working correctly: $list = $page->siblings("content_type!=6,sort=article_publish_date"); $prevPage = $list->getPrev($page); $nextPage = $list->getNext($page); if($prevPage) echo "<i class='icon-chevron-left'></i> <a href='{$prevPage->url}'>" . ${'previous_'.$countryCode} . "</a>"; if($nextPage) echo "<a href='{$nextPage->url}'>" . ${'next_'.$countryCode} . "</a> <i class='icon-chevron-right'></i>"; 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now