Topic: Template menu

I need urgent help with respect to a web template i have successfully integrated with wolf cms.everything seems to be alright except for the menu which came with several drop downs.
Find below the html menu code for the template::

<div id="mainMenu">
            <ul>
                <li class="active"><a href="#"><span>Home</span></a>
                    <ul>
                        <li class="first current"><a href="index.php">Index small header</a></li>
                        <li><a href="index-full.php">Index large header</a></li>
                        <li class="last"><a href="index-headerno.php">Index no header</a></li>
                    </ul>
                </li>
                <li><a href="#"><span>Colors</span></a>
                    <ul>
                        <li class="first"><a onclick="switchSkin('1');" href="#">Orange</a></li>
                        <li><a onclick="switchSkin('2');" href="#">Blue</a></li>
                        <li><a onclick="switchSkin('3');" href="#">Green</a></li>
                        <li class="last"><a onclick="switchSkin('4');" href="#">Black</a></li>
                    </ul>
                </li>
                <li><a href="#"><span>Pre-made pages</span></a>
                    <ul>
                        <li class="first"><a href="pre-whatwedo.php">What we do .v1</a></li>
                        <li><a href="pre-whatwedo2.php">What we do .v2</a></li>
                        <li><a href="pre-whoweare.php">Wo we are</a></li>
                        <li><a href="pre-ourclients.php">Our clients</a></li>
                        <li class="last"><a href="pre-pricetable.php">Pricetable</a></li>
                    </ul>
                </li>
                <li><a href="#"><span>Blog pages</span></a>
                    <ul>
                        <li class="first"><a href="blog-overview.php">Blog overview</a></li>
                        <li class="last"><a href="blog-detail.php">Blog detail</a></li>
                    </ul>
                </li>
                <li><a href="#"><span>Portfolio pages</span></a>
                    <ul>
                        <li class="first"><a href="portfolio-3col.php">Portfolio 3 columns</a></li>
                        <li><a href="portfolio-sidebar.php">Portfolio with sidebar</a></li>
                        <li><a href="portfolio-list.php">Portfolio list</a></li>
                        <li class="last"><a href="portfolio-detail.php">Portfolio detail page</a></li>
                    </ul>
                </li>
                <li><a href="#"><span>Gallery pages</span></a>
                    <ul>
                        <li class="first"><a href="gallery-image.php">Image gallery</a></li>
                        <li><a href="gallery-video.php">Video gallery</a></li>
                        <li class="last"><a href="gallery-mixed.php">Mixed gallery</a></li>
                    </ul>
                </li>
                <li><a href="#"><span>Misc</span></a>
                    <ul>
                        <li class="first"><a href="elements.php">Styled elements</a></li>
                        <li class="last"><a href="column-system.php">Column systems</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- end mainMenu -->

i have used the default navigational codes to no avail

<ul>
      <li<?php echo url_match('/') ? ' class="current"': ''; ?>><a href="<?php echo
URL_PUBLIC; ?>">Home</a></li>
<?php foreach($this->find('/')->children() as $menu): ?>
      <li<?php echo in_array($menu->slug, explode('/', $this->url)) ? '
class="current"': null; ?>><?php echo $menu->link($menu->title); ?></li>
<?php endforeach; ?> 
    </ul>

How do i use wolf cms menu for the html code above.

Thumbs up

Re: Template menu

Do you have the website online somewhere? The default code as you're calling it does work fine... I assume it outputs a menu, just not the one you want...?

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

Re: Template menu

It seems that you want a dropdown menu (or just to show everything at once)!? Check this thread and of course, there is a navigational cookbook with lots of menus.

Wolf CMS Paper Guy
Wolf CMS related blog / journal at Project 79 | Wolf CMS Docs

Re: Template menu

Thank you very much jackie for referring me to this link-http://www.wolfcms.org/forum/topic488.html.
I was able to use this code

<ul id="nav">
      <li><a<?php echo url_match('/') ? ' class="current"': ''; ?> href="<?php echo URL_PUBLIC; ?>">Home</a></li>
<?php foreach($this->find('/')->children() as $menu): ?>
      <li<?php if ($menu->children()) { echo ' class="drop"'; } ?>>
         <?php echo '<a href="#"'.(in_array($menu->slug, explode('/', $this->url)) ? ' class="current"': null).'> <span>'.$menu->title().'</span></a>'; ?>
<?php if ($menu->children()) : ?> 
        <ul>
        <?php foreach($menu->children() as $child) : ?>
            <li><?php echo $child->link() ?></li>
        <?php endforeach; ?>
        </ul>
<?php endif; ?>
      </li>
<?php endforeach; ?> 
</ul>

The drop downs are working but i have a challenge.All the menus without children are not displaying -they all show this # sign.For those with drop downs ,the pages are opening but those without drop downs are not displaying .
Can anyone please help tweak the code above .Im a php newbie.

moderator edit: added code block formatting

Last edited by mvdkleijn (2011-09-01 09:39)

Thumbs up

Re: Template menu

Try this modification, works for me:

<ul id="nav">
      <li><a<?php echo url_match('/') ? ' class="current"': ''; ?> href="<?php echo URL_PUBLIC; ?>">Home</a></li>
<?php foreach($this->find('/')->children() as $menu): ?>
      <li<?php if ($menu->children()) { echo ' class="drop"'; } ?>>
         <?php echo '<a href="'.$menu->slug($menu->link()).'"> <span>'.$menu->title().'</span></a>'; ?>
<?php if ($menu->children()) : ?> 
        <ul>
        <?php foreach($menu->children() as $child) : ?>
            <li><?php echo $child->link(); ?></li>
        <?php endforeach; ?>
        </ul>
<?php endif; ?>
      </li>
<?php endforeach; ?> 
</ul>
Wolf CMS Paper Guy
Wolf CMS related blog / journal at Project 79 | Wolf CMS Docs

Re: Template menu

thank you jackie
it worked fine but please how can i get the drop downs for each menu to appear on each menu page side bars

Thumbs up

Re: Template menu

Assuming that your dropdown menu is somewhere on the top of the page acting as main navigation for your site, you must create a separate "foreach loop" () and call it somewhere in your Layout.  This should help you.

Then it would be wise to put your menu code in "if statement" (check this function)

If you need some assistance, just shout tongue

Wolf CMS Paper Guy
Wolf CMS related blog / journal at Project 79 | Wolf CMS Docs