Page 1 of 1

Navigator bug when using items parameter in 2 menus on page

Posted: Sat Feb 04, 2017 11:48 pm
by d4creative
I have a site with two options for navigation (at my clients request). It involved a main top level items nav bar and a drop down list of 2-tiered navigation menu items. Both nav menus use the "items" parameter to restrict which items appear in the navigation. Some other items appear only in the footer.

See it at http://www.cch.net.au but note that the dropdown menu currently has the items parameter removed. It's ugly as it includes too many items and ruins the layout.

It worked fine in 1.12 and before with the Menu Manager navigation module. Since upgrading to 2.1.6 the navigation is broken, but only when both navigator calls use the "items=" parameter. When I remove the parameter from one of the calls it behaves correctly.

Here is my nav code:

Code: Select all

      <nav>
{* ==== Second tier navigation comes first so it stacks in the correct layering! ==== *}
         <div id="menu2_pos">
            <div id="secondary">
               {Navigator number_of_levels='2' items='about,services,connect,resources,give'}
            </div>
            <div id="menu2_tab">
               <a name="dropdown"><img src="{root_url}/uploads/images/site-design/menu-tab.png" /></a>
            </div>
         </div>

         <div id="menu1_pos">
            <div id="primary">
               <div id="home_logo">
                  <a href="/welcome"><img src="{root_url}/uploads/images/site-design/CCH-Logo-Black.png" /></a>
               </div>
               <h2 class="accessibility">Navigation</h2>
               {Navigator number_of_levels='1' items='about,services,connect,resources,give'}
            </div>
            <div style="clear:both;"></div>
         </div>
      </nav>
{* End Navigation *}

Site installation details:

Code: Select all


[b]Cms Version: 2.1.6[/b]

[b]Installed Modules:[/b]

    AdminSearch: 1.0.2
    CGBlog: 1.14.1
    CGExtensions: 1.53.17
    CGFeedMaker: 1.0.20
    CGFeedback: 1.8.2
    CGSimpleSmarty: 2.1.6
    CMSContentManager: 1.1.4
    CMSMailer: 6.2.14
    Captcha: 0.5.3
    DesignManager: 1.1.1
    FileManager: 1.5.2
    FormBrowser: 0.5
    FormBuilder: 0.8.1.4
    JQueryTools: 1.3.9
    ListIt2: 1.4.1
    MicroTiny: 2.0.3
    ModuleManager: 2.0.5
    Navigator: 1.0.3
    News: 2.50.6
    PodcastManager: 0.6.2
    Printing: 1.1.2
    Search: 1.50.2
    ThemeManager: 1.1.8
    TinyMCE: 3.1.4
    nuSOAP: 1.0.2


[b]Config Information:[/b]

    php_memory_limit:
    max_upload_size: 8000000
    url_rewriting: mod_rewrite
    page_extension: /
    query_var: page
    auto_alias_content: true
    locale:
    set_names: true
    timezone: Australia/Sydney
    permissive_smarty: false


[b]Php Information:[/b]

    phpversion: 5.4.29
    md5_function: On (True)
    json_function: On (True)
    gd_version: 2
    tempnam_function: On (True)
    magic_quotes_runtime: Off (False)
    E_ALL: 22527
    E_STRICT: 0
    E_DEPRECATED: 0
    test_file_timedifference: No time difference found
    test_db_timedifference: No time difference found
    create_dir_and_file: 1
    memory_limit: 128M
    max_execution_time: 30
    register_globals: Off (False)
    output_buffering: 4096
    disable_functions:
    open_basedir:
    test_remote_url: Success
    file_uploads: On (True)
    post_max_size: 8M
    upload_max_filesize: 8M
    session_save_path: /tmp (1777)
    session_use_cookies: On (True)
    xml_function: On (True)
    xmlreader_class: On (True)
    check_ini_set: On (True)
    curl: On


[b]Performance Information:[/b]

    allow_browser_cache: On (True)
    browser_cache_expiry: 30
    php_opcache: Off (False)
    smarty_cache: On (True)
    smarty_compilecheck: Off (False)
    smarty_cache_udt: On (True)
    auto_clear_cache_age: On (True)

[b]Server Information:[/b]

    Server Software: Apache/2.2.3 (CentOS)
    Server Api: cgi-fcgi
    Server Os: Linux 2.6.18-417.el5 On x86_64
    Server Db Type: MySQL (mysql)
    Server Db Version: 5.5.37
    Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable


[b]Permission Information:[/b]

    tmp: /var/www/vhosts/cch.net.au/httpdocs/tmp (0755)
    tmp_cache: /var/www/vhosts/cch.net.au/httpdocs/tmp/cache (0777)
    templates_c: /var/www/vhosts/cch.net.au/httpdocs/tmp/templates_c (0777)
    modules: /var/www/vhosts/cch.net.au/httpdocs/modules (0755)
    uploads: /var/www/vhosts/cch.net.au/httpdocs/uploads (0755)
    File Creation Mask (umask): /var/www/vhosts/cch.net.au/httpdocs/tmp/cache (0777)
    config_file: 0440

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Sun Feb 05, 2017 10:30 am
by rotezecke
what does the default template (navigator) look like?

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Sun Feb 05, 2017 10:11 pm
by d4creative
A good question. :)
I'm using the "Simple Navigation" template (unaltered from default).

Code: Select all

{* simple navigation *}
{* note, function can only be defined once *}
{* 
  variables:
  node: contains the current node.
  aclass: is used to build a string containing class names given to the a tag if one is used
  liclass: is used to build a string containing class names given to the li tag.
*}

{function name=Nav_menu depth=1}{strip}
<ul>
  {foreach $data as $node}
    {* setup classes for the anchor and list item *}
    {assign var='liclass' value='menudepth'|cat:$depth}
    {assign var='aclass' value=''}

    {* the first child gets a special class *}
    {if $node@first && $node@total > 1}{assign var='liclass' value=$liclass|cat:' first_child'}{/if}

    {* the last child gets a special class *}
    {if $node@last && $node@total > 1}{assign var='liclass' value=$liclass|cat:' last_child'}{/if}

    {if $node->current}
      {* this is the current page *}
      {assign var='liclass' value=$liclass|cat:' menuactive'}
      {assign var='aclass' value=$aclass|cat:' menuactive'}
    {/if}

    {if $node->parent}
      {* this is a parent of the current page *}
      {assign var='liclass' value=$liclass|cat:' menuactive menuparent'}
      {assign var='aclass' value=$aclass|cat:' menuactive menuparent'}
    {/if}

    {if $node->children_exist}
      {assign var='liclass' value=$liclass|cat:' parent'}
      {assign var='aclass' value=$aclass|cat:' parent'}
    {/if}

    {* build the menu item node *}
    {if $node->type == 'sectionheader'}
      <li class='sectionheader {$liclass}'><span>{$node->menutext}</span>
        {if isset($node->children)}
          {Nav_menu data=$node->children depth=$depth+1}
        {/if}
      </li>
    {else if $node->type == 'separator'}
      <li class='separator {$liclass}'><hr class='separator'/></li>
    {else}
      {* regular item *}
      <li class="{$liclass}">
        <a class="{$aclass}" href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>
        {if isset($node->children)}
          {Nav_menu data=$node->children depth=$depth+1}
        {/if}
      </li>
    {/if}
  {/foreach}
</ul>
{/strip}{/function}

{if isset($nodes)}
{Nav_menu data=$nodes depth=0}
{/if}

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Mon Feb 06, 2017 2:25 pm
by rotezecke
you could try to clone the nav template and use different calls:

Code: Select all

{Navigator items='alias1,alias2,alias3' number_of_levels=2 template=myA}
...
{Navigator items='alias1,alias2,alias3' number_of_levels=1 template=myB}

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Tue Feb 07, 2017 9:16 am
by velden
Just checked in default 2.1.6 and seems to work.

Can you eleborate on the "the navigation is broken" part?

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Tue Feb 07, 2017 10:01 am
by d4creative
The menu item which is supposed to display two levels does not display the second tier, only the "items" but not the "children" (levels=2).

Code: Select all

<div id="secondary">
               {Navigator number_of_levels='2' items='about,services,connect,resources,give'}
</div>
If I remove the "items" parameter it shows all menu items correctly, but as soon as I specify "items" in more than one Navigator call one is broken.

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Tue Feb 07, 2017 10:12 am
by velden
Let me show my code and result (default CMSMS 2.1.6 install)
2017-02-07 11_09_42-template.png
2017-02-07 11_09_12-[#] CMS Made Simple 2.1.6 - How CMSMS Works.png
Seems what is expected to me.

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Tue Feb 07, 2017 11:04 am
by d4creative
Your code is not identical to mine as you've included the loadprops parameter, and your lists of items are not the same in both menus.

Perhaps try using both menus with the same items. The menu I was requested to construct uses a top row of 'fixed' links with no drop-down submenus, then there is a drop-down option that reveals the same top-level links as well as their sub-menu items.

Look at this site to see what I mean: http://www.cch.net.au

In the meantime, I found that hiding/disabling the other top level links from the menu, but forcing a "show_all" parameter in the footer made them still display where I wanted them (ie. footer-only items).

Perhaps there's some other weird thing going on. I don't know...

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Tue Feb 07, 2017 12:15 pm
by velden
As per your request ('Simple Navigation' template is set as default Navigator template):
2017-02-07 13_12_55-[#] Design Manager - CMS Made Simple 2.1.6.png
2017-02-07 13_12_55-[#] Design Manager - CMS Made Simple 2.1.6.png (8.82 KiB) Viewed 5367 times
2017-02-07 13_12_01-[#] CMS Made Simple 2.1.6 - How CMSMS Works.png

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Tue Feb 07, 2017 12:59 pm
by d4creative
Oh well...
It's a puzzle, but as I've found a workaround I'm not too bothered. IMO the menus on the website in question need an overhaul so it may disappear once I've cleaned up the jquery etc.

Thanks for your time looking into it.

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Wed Feb 08, 2017 4:38 pm
by DIGI3
Is it possible you're using the same function name in both templates? These need to be unique.

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Wed Feb 08, 2017 10:53 pm
by d4creative
Not sure which function or template you mean... The page template or the menu template? If you mean in the menu template, then by that argument you could never call two menus of the same template on the same page, but doing that is clearly working for others.

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Wed Feb 08, 2017 10:55 pm
by DIGI3
In the Navigator template you pasted, it has a function name:

{function name=Nav_menu depth=1}

This can only be used once. In fact, if you look a few lines above it, you'll see: {* note, function can only be defined once *}

You don't *have* to use functions, but if you *do* use them, then you are correct, you can't call the template twice on the same page.

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Wed Feb 08, 2017 11:06 pm
by d4creative
I saw that in the template code, but veldon (Dev Team above) does exactly that and it works fine. I think that means only once with an instance/within a menu template. If the Navigator is called twice in the page using the same template it seems to work fine for him, and previously worked fine for me also.

Re: Navigator bug when using items parameter in 2 menus on p

Posted: Wed Feb 08, 2017 11:14 pm
by DIGI3
Well, reusing the function is what's causing the issue. You could verify that by duplicating the template and giving the duplicate a different function name (it's referenced 4 or 5 times through the template, for recursion, so change all of those).
If it's working in some situations then that's just due to what's in the function, and if you're calling it with the same parameters, etc.