Page 1 of 1

cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Thu Sep 11, 2008 11:08 pm
by Benek
I'd like to use the {cms_selflink dir="next"} tag to create automatic links to the next page, but I find it very confusing to users that it will link to the next page in your site even if that page is on a completely different level.

I need a next page link that will only show up if there is a next SIBLING page to link to. If the current page is the last page within it's parent, then there should be no next link as there is no logical page to link to.

I've looked through all of the tags parameters and there doesn't seem to be a way to do it. I've searched extensively on this forum and many people have asked the same thing but I cannot find a definitive answer for how to do it. I'd prefer to add some PHP logic straight to my template (or put it in a custom tag) that says something like:

if (this page has a next sibling) {
cms_selflink dir="next"
} else (if this is the last page in this group) {
show nothing
}

I don't know PHP otherwise I imagine this would be simple to write. Can anyone help me out to get this functionality or share other solutions you have found?

Re: cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Sat Sep 13, 2008 9:49 pm
by Benek
Anyone? Please help!

Re: cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Sun Sep 14, 2008 3:26 am
by Dr.CSS
Have you tried to look into the pagination tag alby wrote?...

Re: cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Sun Sep 14, 2008 3:34 am
by Benek
Where can I find that? Didn't see anything like that on the shared tags page. Is there another collection of shared user-defined tags I don't know about?

Re: cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Sun Sep 14, 2008 3:38 am
by Dr.CSS
If you find a post that alby has you will find link at the bottom in signature...

Re: cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Sun Sep 14, 2008 3:48 am
by Benek
OK, found it. Had a look. I don't think it's what I need. I'm not trying to break up large pages into smaller sections like that. I really just need something that works with the normal next/prev links but makes them smarter so they don't lead to completely unrelated pages outside the current parent.

Any other ideas?

Re: cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Sun Sep 14, 2008 3:53 am
by Dr.CSS
Well thought it might give an ides on how to change self link, as it doesn't have that function atm...

Re: cms_selflink dir="next" only if there is a next SIBLING page?

Posted: Wed Sep 17, 2008 12:04 am
by Benek
I looked through Alby's pagination code and I couldn't find anything that looked like it was checking to see if there were sibling pages. I don't think I'm going to get ideas from that.

Any other suggestions for how to achieve next page links only if a next sibling page exists in that section? It would be a really useful feature. I think without it the next/prev self_link tag is almost useless.

Re: cms_selflink dir=

Posted: Wed May 25, 2011 4:58 pm
by _luki
I know that this topic is 3 years old, but I've encountered same problem lately. My solution is to use CGSimpleSmarty and check next sibling like this:

Code: Select all

{if $cgsimple->get_sibling(-1)}
	{cms_selflink dir="prev"}
{/if}
{if $cgsimple->get_sibling(1)}
	{cms_selflink dir="next"}
{/if}
Hope it's helpful