Great piece of code there, very handy. I was wondering if someone could help extending it further?
I have my snippet:
<?php
$output = '';
$id = $modx->documentIdentifier;
$levelcount = count($modx->getParentIds($id));
if ($levelcount == 1) {
$output = '{{sideNav2deep}}';
} elseif ($levelcount == 2) {
$output = '{{sideNav3deep}}';
} elseif ($levelcount == 3) {
$output = '{{sideNav4deep}}';
} elseif ($levelcount == 4) {
$output = '{{sideNav5deep}}';
} else $output= '{{sideNav}}';
return $output;
?>
Is there a way to detect that there are no more children of the current document and display a different chunk?
What I am trying to achieve is BBC Sport style navigation:
http://news.bbc.co.uk/sport where you click on Football, you have the parent page at the top of the list (Football) highlighted, and then the children of Football. Click Premier League, and you go deeper again. But click results and you go no deeper, the children of premier league still show. With the snippet above, it would go to results but not have any children as that would be the last in the list. So I need a way for it to automatically detect and load a suitable chunk. But this may not be the case all the time! - Which makes me think that it should be a tickbox in a TV that lets the user specify.
What’s the best solution?
Cheers