Link to sibling page(s)

Permalink
I want to put Next and Previous buttons to allow the user to navigate through sibling pages (all pages under the same parent).

1. How would I dynamically find the previous and next sibling pages (specifically the links to them)?

2. How would I test for the first and last items (e.g. no previous sibling, or no next sibling)?

Thanks for any help on this!

webinstinct
 
site replied on at Permalink Reply
site
Have you tried the "Next and Previous Nav" block? It's about half way down in the "Add Block" dialogue.

The code for that block may be a great reference if its not what you are looking for.
webinstinct replied on at Permalink Reply
webinstinct
Thanks Paul. I found exactly that and it worked perfectly. I had not noticed=
that new block in the recent release but it was just what I needed. Thanks s=
o much for the follow up!



On Jan 14, 2011, at 9:03 AM, Concrete5 Community <discussions@concretecms.co=
m> wrote:

>=20
TimDix replied on at Permalink Reply
TimDix
Late reply, but I needed to get the same information, here's my solution (based off next_previous block as recommended above). I don't actually render the block, but this gives me references to the prev/next pages.

$bt_main = BlockType::getByHandle('next_previous');
$bt_main->controller->loopSequence = true;
$prev = $bt_main->controller->getPreviousCollection();
$next = $bt_main->controller->getNextCollection();