Menu / Sub Menu / Autonav fun

Permalink
Hi Guys,

Happy New Year. Started with Concrete yesterday and almost managed to port a site into it in a day - terrific product. I have run into a problem with the autonav though and hoping someone might be able to help.

The site I am porting ishttp://www.discovery.net.au/

The C5 dev environment can be seen here:
http://discovery.net.au/dev/

This post pertains the the nav menu's at the top (Products / Communications / Consultancy Services / Solution) As you will see on the live site, each of these are parents to a drop down nested list menu.

The problem I seem to be having is that the autonav doesn't appear to be nesting the child menus in the parents correctly. On this pagehttp://discovery.net.au/dev/index.php/products/... I have edited the nav settings to be:

Pages Should appear = in their site map order
Display Pages = at the top level
Sub pages to Display = relevant sub pages
Sub- page level = Display all

With these, you'll see that the menu is happening, but Communications / Consultancy Services / Solution are appearing as children of "Products"

I know it can be done because these guys are doing it!
http://www.circlekwest.com/

I've tried to write my own version of header_menu.php but didn't get very far. Anyone got some ideas of what i am doing wrong?

Cheers

 
synlag replied on at Permalink Reply
synlag
ok I can't see what you did wrong actually, but here are some tips how to implement the dropdown menu:

http://de.selfhtml.org/css/layouts/navigationsleisten.htm...

You'll only need the two examples from the bottom.
ben replied on at Permalink Reply
Thanks for responding. I'm pretty certain that the CSS is OK as it is working OK on the live version and I am using the same CSS in my theme. The issue is that for whatever reason, C5 is not outputting the <ul> as defined in the site map. ie: I am getting

<ul>
<li>Products
<ul>
<li>Product 1</li>
<li>Product 2</li>
<li>Product 3</li>
<li>Communications</li>
<li>Consultancy Services</li>
<li>Solutions</li>
</ul>

whereas it should be

<ul>
<li>Products
<ul>
<li>Product 1</li>
<li>Product 2</li>
<li>Product 3</li>
</ul>
<li>Communications</li>
<li>Consultancy Services</li>
<li>Solutions</li>
</ul>
frz replied on at Permalink Reply
frz
I think you've got the settings off in the auto-nav block. They are annoyingly complex and need to be simplified. How about trying some of the options for the two sub page choices at the end and looking in the preview pane of the block in edit mode.. can you get the tree looking right there?
ben replied on at Permalink Reply
In the preview with the settings mentioned above, the list displays as it should - which now makes me think it is something wrong with my code. I'll have another look in a couple of hours with a fresh(er) set of eyes.
spiral replied on at Permalink Reply
spiral
I'm having the exact same problem. The preview shows a nested list, but when i publish, the result is <li>s on the same level.
spiral replied on at Permalink Reply
spiral
weird. when i insert the autonav, it works as expected, (nested <ul>s)but as soon as I turn it into a custom template (header menu) it stops working (turns into all one level <li>)!

I guess it's cause if i look at header_menu.php, there doesn't seem to be (from my limited php knowledge) any hints of nested lists.

Anyone that can give a non-programmer any clues as to how to fix this?
spiral replied on at Permalink Reply
spiral
just talking to myself here, hehe, but i found the solution. i just copied the code from blocks/autonav/view.php to blocks/autonav/templates/header_nav.php, but keeping the class "nav-header". it seems to be working fine.


:D

hopefully my ramblings will be of use to someone else
frz replied on at Permalink Reply
frz
sounds like it was just a CSS issue..

glad you helped yourself in public. ;)
ben replied on at Permalink Reply
Hey Spiral - I'm away at the moment so can't check to be sure, but this definitely sounds like the same issue that I was seeing. Thanks for posting up your findings - very helpful indeed.
spiral replied on at Permalink Reply 1 Attachment
spiral
nope, it was not a css issue.

the php template used for header_nav actually does not produce nested <li>s, even though the one for a regular autonav does.

i had to change the php in that file to get it to work.

I am enclosing the fixed header_menu.php in case it helps someone else.
andrew replied on at Permalink Reply
andrew
Instead we just use the regular autonav template, but make sure that when we use it at the top of the page, the CSS for that particular instance displays it like the header menu
spiral replied on at Permalink Reply
spiral
the basic difference just seems to be the class applied to it.
gilly replied on at Permalink Reply
I dropped in that header_menu.php file, which converted my menu froma table based menu to a list based menu, which is great, however...

The sub menu items are not showing up at all. Its not a css issue, I'm purely talking about getting the structure right in the html for a 2-level dropdown menu (the same as Ben describes above).

I am complete newbie to C5, and the site I am building wasnt built by me (I am finishing off someone elses unfinished project). When I check the sitemap in the admin area though, there are about 5 main menu items, each with sub menu items. Their properties show that they havent been excluded from the nav.

In the template file, I am using this code:

<div id="mainmenu">
   <?php
   $a = new Area('Header Nav');
   $a->setBlockLimit(1);
   $a->display($c);
   ?>
</div>


Any ideas why its not working?

The html that is displaying looks like this:

<div id="mainmenu">
<ul class="nav-header">
<li><a href="link1/">Link 1</a></li>
<li><a href="link2/">Link 2</a></li>
</ul>
</div>
frz replied on at Permalink Reply
frz
when you put the actual block in edit mode, do you see the child pages in the preview pane? If not, there's something off about the settings in that block - it doesn't know you want to pass that much of the tree to the presentation layer.
gilly replied on at Permalink Reply
the child pages werent showing. So to get them to show, it seems I need to edit every single page of my website, to get the sub-menu items to show on every page.

Is there a 'site-wide' option to be able to do this?
frz replied on at Permalink Reply
frz
well it depends on how the site was made, but if you goto defaults for that page type in the dashboard you might be able to do it from there.
gilly replied on at Permalink Reply
I did have a look at these, but there didnt seem to be many options. All it had was 'exclude from nav', which is unchecked anyway.

Perhaps I need to create a custom page attribute, that specifies that the page needs to display all sub pages, display a custom amount of sub pages, and then set this to 1.

But I have no idea of how to go about that!
paulfeakins replied on at Permalink Reply
paulfeakins
I had the same problem but I fixed it in the same way as spiral - copy the code from view.php! Seems to do the job nicely.
Paul.
http://www.Antropy.co.uk
goon replied on at Permalink Reply
Guys, I did replace header_menu.php with view.php keeping the nav-header class and even just used spiral file attached here, however I can not make the header menu to show sub menus when i roll my mouse over it.
Just started yesterday with C5 and need some help. Thanks in advance.
Need to have rollover sub menu to show up in header menu
awebpage replied on at Permalink Reply
awebpage
Thanks for this post. Worked like a charm.

For the others who are banging on about it being a CSS/other issue.
The cause of this problem is the templates (header_menu.php etc) do not include the required php calls to produce nested lists.

A lot of people (myself included) were modifying header_menu.php and was left wondering why nested lists were not being produced.

Copying the code from /blocks/autonav/view.php into a custom template works wonders. Its well commented and very useful.
DerCommodore replied on at Permalink Reply
I had the same problem
Here is the clean answer:

header_menu.php
<?php 
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $aBlocks = $controller->generateNav();
   global $c;
   echo("<ul class=\"nav-header\">");
$nh = Loader::helper('navigation');
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
      if (!$_c->getCollectionAttributeValue('exclude_nav')) 
      {   
         $thisLevel = $ni->getLevel();
         if ($thisLevel > $lastLevel) 
         {
            echo("<ul class='sub_navi'>");
         } else if ($thisLevel < $lastLevel)
jamils replied on at Permalink Reply
Great. Thanks very much, DerCommodore. That's just what I needed.

Like many people here, I was getting a list of 'li's with no 'ul's.
DtotheOR replied on at Permalink Reply
DtotheOR
Okay, I think if you replace your header_menu.php file with the one provided in the thread your header nav should show nested lists. However, I found that the fix only took effect if I logged into editing mode first. I have no idea why.