Making Automatic Navigation System #122
taufik-nurrohman
started this conversation in
Ideas
Replies: 1 comment
-
|
To add submenu feature: ---
title: Store
description: Download custom extension and layout for free and for a small fee.
menus:
'/store/extension/1': Extension
'/store/layout/1': Layout
...
Content goes here.<ul>
<?php foreach ($links as $link): ?>
<li>
<a href="<?= $link->url; ?>">
<?= $link->title; ?>
</a>
<?php if ($menus = $link->menus): ?>
<ul>
<?php foreach ($menus as $k => $v): ?>
<li>
<a href="<?= $k; ?>">
<?= $v; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What I do in almost all Mecha’s layout system is to make a variable named
$linksin which it contains the data of the root page objects to be applied as navigation menu somewhere in the layout files.In
.\lot\y\*\index.phpfile, I do this:In
.\lot\y\*\nav.phpfile, then I can print out the$linksvariable as navigation items:<nav> <ul> <li> <a href="<?= $url; ?>"> <?= i('Home'); ?> </a> </li> <?php foreach ($links as $link): ?> <li> <a href="<?= $link->url; ?>"> <?= $link->title; ?> </a> </li> <?php endforeach; ?> </ul> </nav>Current state can be added dynamically via
$page->__set()method and the like, to add custom page properties within the loop:You can also utilize every internal properties added to the page file itself, for example, to control the navigation link visibility:
Beta Was this translation helpful? Give feedback.
All reactions