I tried to creates something, but it gets to complicated for my liking.
Maybe I'm missing the obvious. Following code I check how many parents there are form the root and depending on that output childs or siblings.
<?php
// start building content navigation on top
$content_nav = '';
// build 4th level navigation only
foreach($page->parents as $level => $p){
// build when on 2th level
if(count($page->parents) == 3){
if($level == 2 and count($page->children) > 0){
$p3 = $page;
$out = '';
$found = $p3->children("template=sub-page|sub-page-wide|list-sub-page|sub-page-iframe");
if($found){
foreach($found as $child){
if($child === $page) $class = " on"; else $class= '';
$out .= "\n\t\t<a class='ajaxy-page{$class}' href='{$child->url}'>$child->title</a> | ";
}
$content_nav = "\n\t\t<div class='content-nav'>";
// remove last 2 chars from string to remove last "|"
$content_nav .= substr($out,0,strlen($out)-2)."</div>";
echo $content_nav;
}
}
}
// build when on 3th level
if(count($page->parents) == 4){
if($level == 3){
$p3 = $p;
$out = '';
$found = $p3->children("template=sub-page|sub-page-wide|list-sub-page|sub-page-iframe");
if($found){
foreach($found as $child){
if($child === $page) $class = " on"; else $class= '';
$out .= "\n\t\t\t<a class='ajaxy-page{$class}' href='{$child->url}'>$child->title</a> | ";
}
$content_nav = "\n\t\t<div class='content-nav'>";
// remove last 2 chars from string to remove last "|"
$content_nav .= substr($out,0,strlen($out)-2)."</div>";
echo $content_nav;
}
}
}
}
I have a simpler example which is better I think, but I would love to may hear alternatives, or ideas although I can't think of anything else atm.
<?php
if($page->parents->count() == 3 and $page->numChildren > 0) {
echo "<ul>";
foreach($page->children as $child){
$class = $child === $page ? 'class="active"' : '';
echo "\n<li><a href='$child->url' {$class}>{$child->title}</a></li>";
}
echo "</ul>";
}
if($page->parents->count() > 3) {
echo "<ul>";
foreach($page->parent->children as $child){
$class = $child === $page ? 'class="active"' : '';
echo "\n<li><a href='$child->url' {$class}>{$child->title}</a></li>";
}
echo "</ul>";
}













