Page 1 of 1

MenuManager/Navigator differences with CMS upgrade to v2

Posted: Sat Jun 30, 2018 8:44 pm
by 10010110
So, I’m upgrading a site from CMS 1.12.2 to version 2 and am experiencing differences in the way the Navigator module displays my menu structure compared to how MenuManager did it.

My default menu template in MenuManager looked like this:

Code: Select all

{if $count > 0}
<ul class="nav">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}

{if $node->current == true}
<li class="current"><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>
{elseif $node->parent == true and $node->type != 'sectionheader' and $node->type != 'separator'}
<li class="current parent"><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>
{elseif $node->type == 'sectionheader'}
<li class="section">{$node->menutext}
{elseif $node->type == 'separator'}
<li class="separator"><hr/>
{else}
<li><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>
{/if}
{/foreach}
{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}
which is pretty similar in logic/structure to the minimal_menu.tpl template that came with the CMS (verson 1), except a few different class names.
I was calling the menu on my pages with this tag:

Code: Select all

{menu loadprops=0 number_of_levels='2' items='verein, projekte'}
This showed the two page items and their direct children as sub lists. However, this doesn’t seem to work anymore with the Navigator; in the new version it just shows the two page items and no children. Has this been a bug in MenuManager that has been “fixed” now, where I have to find a different implementation in order to get the same functionality or is there anything else I’m missing?

Re: MenuManager/Navigator differences with CMS upgrade to v2

Posted: Sat Jun 30, 2018 11:45 pm
by DIGI3
I just tried this in Navigator with various default Navigator templates and it works fine.

Re: MenuManager/Navigator differences with CMS upgrade to v2

Posted: Sun Jul 01, 2018 11:34 am
by 10010110
Hm, that’s strange. For me it only shows the two items specified in the module tag and not their children, regardless of which template I’ve selected as default.

This is my current template code, derived from the minimal menu template and slightly adapted:

Code: Select all

{if !isset($depth)}{$depth=0}{/if}

{if isset($nodes)}{strip}
<ul class="nav">
  {foreach $nodes as $node}
    {if $node->type == 'sectionheader'}
      {* section header *}
      <li class="sectionheader{if $node->parent} activeparent{/if}">
        {$node->menutext}
        {if isset($node->children)}
          {include file=$smarty.template nodes=$node->children depth=$depth+1}
        {/if}
      </li>
    {else if $node->type == 'separator'}
      <li style="list-style-type: none;"><hr class="separator"/></li>
    {else}
      {* regular item *}
      {$liclass=''}
      {if $node->current}
        {$liclass='current'}
      {elseif $node->parent}
        {$liclass='current parent'}
      {/if}
      <li{if $liclass != ''} class="{$liclass}"{/if}>
        <a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>
        {if isset($node->children)}
          {include file=$smarty.template nodes=$node->children depth=$depth+1}
        {/if}
      </li>
    {/if}
  {/foreach}
</ul>
{/strip}{/if}
and I’m calling it with

Code: Select all

{Navigator loadprops=0 number_of_levels='2' items='verein, projekte'}
As said, it only shows the two items specified, not their sub items. But I want the sub items to also show up.

Re: MenuManager/Navigator differences with CMS upgrade to v2

Posted: Sun Jul 01, 2018 2:55 pm
by DIGI3
I did a clean install with default content, and created a Navigator template with the code you pasted. Then on the home page (Simplex) I added:

Code: Select all

{Navigator items='about-cmsms,help' number_of_levels=3 loadprops=0 template='stephan'}
And it works fine, shows the two parent pages and their children.

I would start to diagnose what's different. Are the child pages set to show in the menu? Are they active? Does it work with different parent pages?

Re: MenuManager/Navigator differences with CMS upgrade to v2

Posted: Sun Jul 01, 2018 9:49 pm
by 10010110
Hm, interesting. After many tries and fails it turns out the order of the attributes matters. It doesn’t work in this order:

Code: Select all

{Navigator loadprops=0 number_of_levels=2 items='verein, projekte'}
but it does work in this order:

Code: Select all

{Navigator loadprops=0 items='verein,projekte' number_of_levels=2}
i. e. the number_of_levels must come after the items.

Is this a bug? It’s not explicitly mentioned in the documentation (only implicitly by an example which happens to show the correct order).

Re: MenuManager/Navigator differences with CMS upgrade to v2

Posted: Sun Jul 01, 2018 11:59 pm
by DIGI3
Not sure if it's a bug per se, but probably something we can either improve and/or document.

For now, I've added a note to the docs site: https://docs.cmsmadesimple.org/layout/d ... /navigator

Re: MenuManager/Navigator differences with CMS upgrade to v2

Posted: Mon Jul 02, 2018 6:56 am
by 10010110
Thanks. Yeah, that’s definitely something to improve; it used to work in MenuManager and much like in HTML the order of properties shouldn’t matter.