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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Benek

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

Post 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?
Benek

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

Post by Benek »

Anyone? Please help!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

Have you tried to look into the pagination tag alby wrote?...
Benek

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

Post 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?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

If you find a post that alby has you will find link at the bottom in signature...
Benek

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

Post 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?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

Well thought it might give an ides on how to change self link, as it doesn't have that function atm...
Benek

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

Post 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.
_luki

Re: cms_selflink dir=

Post 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
Locked

Return to “CMSMS Core”