Hello everybody,
I am using a treemenu snippet, as suggested here: https://github.com/bastianallgeier/kirbycms-extensions/tree/master/snippets/treemenu.
My snippet:
<?php if(!isset($subpages)) $subpages = $pages->find('artists')->children() ?>
<ul>
<?php foreach($subpages->visible() as $p): ?>
<li class="depth-<?php echo $p->depth() ?>">
<a<?php echo ($p->isActive()) ? '
class="active"' : '' ?> href="<?php echo $p->url() ?>"><?php echo $p->title() ?></a>
<?php if($p->hasChildren()): ?>
<?php snippet('treemenu', array('subpages' => $p->children())) ?>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
Background:
A website for an exhibition, with a representation space for each artist. The artist has the choice to start with a template (default, portfolio, blog) and then (if desired) add more pages to this page .
This is the topography for the “artists” page and hierarchy:
home/
artists/
artist 1 = default/ (first level)
subpage = blog (second level)
sub-subpage = blogarticle/
subpage = portfolio/
sub-subpage = portfolioitem/
artist 2 = blog/
subpage = blogarticle/
subpage = default/
subpage = portfolio/
sub-subpage = portfolioitem/
artist 3 = portfolio/
subpage = portfolioitem/
subpage = default/
subpage = blog/
sub-subpage = blogarticle/
“Subpage” = relative subpage; relative to “artist…”
Here are several challenges for the submenu, and I hope I can get some help:
1. Remove the blogarticles and the portfolioitems from the menu
Should be done with something like
$excluded = $page->children()>filterBy('template', 'blogarticle') ...;
foreach($page->children()->not($excluded) as $subpage):
But I still didn’t got it to work.
2. Display the artist’s page and the subpages onto one level in the menu
Something like this: John Doe - Blog - Documents - Biography
That could be achieved with CSS, but maybe there is a simpler way to do it?