Hi,
i used the selectbox menu code from http://getkirby.com/docs/solutions/menus#selectbox-menu on my page.
But now i get only the main entries of the menu, but i want to add the subpages too.
How can i do that?
Thanks in advance
Chris
Hi,
i used the selectbox menu code from http://getkirby.com/docs/solutions/menus#selectbox-menu on my page.
But now i get only the main entries of the menu, but i want to add the subpages too.
How can i do that?
Thanks in advance
Chris
Try this …
<?php
// main menu items
$items = $pages->visible();
// only show the menu if items are available
if($items->count()):
?>
<select onchange="window.location.href = this.value">
<?php foreach($items as $item): ?>
<option value="<?php echo $item->url() ?>"<?php e($item->isOpen(), ' selected="selected"') ?>><?php echo $item->title()->html() ?></option>
<?php // check for visible subpages ?>
<?php if($item->hasVisibleChildren()): ?>
<?php foreach($item->children()->visible() as $subitem): ?>
<option value="<?php echo $subitem->url() ?>"<?php e($subitem->isOpen(), ' selected="selected"') ?>>- <?php echo $subitem->title()->html() ?></option>
<?php endforeach ?>
<?php endif ?>
<?php endforeach ?>
</select>
<?php endif ?>
That worked great @flokosiol - thank you!
But one more thing… One of my Main Pages is a Blog! I don’t want to see all the blog entries in the menu, so i need to exclude “blog” from displaying its subpages. All the other Main Pages should display their subpages.
EDIT: Fount this Hiding all subpages of a page from the menu and it worked great
Thanks again
Great!
It would be nice, if you could change the category of your topic to SOLVED. Thanks.