How to set nested (or pulldown) menus

Here is a quick tip on how to set up nested or pull-down menus.

Here is what the default menu looks like in the default template:

<ul><?php foreach($menus['main'] as $item): ?>
<li>
<a href="<?php echo $item['link']; ?>" title="<?php echo $item['title']; ?>"<?php if($item['accesskey']!=''): ?> accesskey="<?php echo $item['accesskey']; ?>"<?php endif; ?><?php if(!empty($item['section']) && $item['section']==$section[0]): ?> id="current"<?php endif; ?>><span><?php echo $item['name']; ?></span></a>
</li>
<?php endforeach; ?></ul>

There are many ways to add a nested menu. Below is a simple one.

You first need to define a new set of submenu in your settings and name the submenu name the same as one section name of the main menu.

Secondly, call menu_2 in appropriate pages.

Thirdly, add the submenu to the main menu by changing the following in your templae file.

Change:
<?php if(!empty($item['section']) && $item['section']==$section[0]): ?>
To:
<?php if(!empty($item['section']) && $item['section']==$section[0]): if($menu_2&&($menu+2==$section[0]){$menu_nested=true; } ?>

Right before

</li>
<?php endforeach; ?></ul>
Add the following:

<php if($menu_nested): ?>

<ul>
<?php foreach($menus[$menu_2] as $item): ?><li><a href="<?php echo $item['link']; ?>" title="<?php echo $item['title']; ?>"<?php if($item['accesskey']!=''): ?> accesskey="<?php echo $item['accesskey']; ?>"<?php endif; ?><?php if(!empty($item['section']) && $item['section']==$section[1]): ?> id="current2"<?php endif; ?>><?php echo $item['name']; ?></a>
</li><?php endforeach; ?>
</ul>

<?php endif; ?>

You now have nested menus. Please report back if you encounter any problems.

Notice you can also have a pulldown menu with some minor changes to the above technique.

Website designed and maintained by ZoriaMEDIA.com

© 2010-2020 the RiteCMS Project

RiteCMS is a free software released under GNU/GPL license. PhpSqliteCMS is under GNU/GPL license. TinyMCE is under GNU/LGPL license.
EazyMobile™ is a trademark of ZoriaMedia.com. RiteCMS & Logos, all contents of this website are © of the RiteCMS project.

Powered by RiteCMS