Footer menu best solution


I want the normal header menu and a footer menu
Normal menu powered by the normal pages

Footer menu pages
2 collums which each 5 pages and these get each 4 subpages
What is the best solution to build the footer menu?

The main pages get all sub pages listed with a short description

Create new page template or use the normal pages ?


You don’t need a new template for the menu. Templates are the main HTML entry point when rendering a specific page type, but I guess the footer is supposed to be shown on all pages of the site.

For navigation it generally makes sense to create a snippet with the required code to generate the menu. You can then embed that snippet in every template, just like the existing footer snippet in the starterkit. You can even modify the existing snippet to include your new menu.

The menu can be generated by using a loop like this one:

<?php foreach($pages as $mainPage): ?>
  <div class="navigation-section">
    <a href="<?php echo $mainPage->url() ?>"><?php echo $mainPage->title() ?></a>

    <?php foreach($mainPage->children() as $subPage): ?>
      <div class="navigation-subpage">
        <a href="<?php echo $subPage->url() ?>"><?php echo $subPage->title() ?></a>
        <?php echo $subPage->shortDesc()->kirbytext() ?>
    <?php endforeach ?>
<?php endforeach ?>
1 Like