Smarty 3 change broke my nav (1.10 to 1.11)

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1457
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Smarty 3 change broke my nav (1.10 to 1.11)

Post by paulbaker »

Upgrading a very old inherited site.

I have a line in Menu Manager that worked fine in 1.10.3:

Code: Select all

{assign var='submenu' value="submenu"|cat:$node->depth-1}
However now I have moved on to 1.11.13 (Smarty 3), instead of generating a value of "submenu2" for example, it outputs only "-1" which breaks the navigation.

What do I need to change to get this working please? (Apart from my knowledge level of Smarty 3 ;D )

Here's the full nav code for context, it's a superfish menu, line in question is line 27.

Code: Select all

{assign var='number_of_levels' value=10000}
{if isset($menuparams.number_of_levels)}
  {assign var='number_of_levels' value=$menuparams.number_of_levels}
{/if}

{if $count > 0}


	{* find last first depth node *}
	{assign var='first' value=0}
	{foreach from=$nodelist item='node'}
		{if $node->depth == 1}
			{if $first < 1}
				{assign var='firstnode' value=$node->id}
				{assign var='first' value=1}
			{/if}
			{assign var='lastnode' value=$node->id}
		{/if}
	{/foreach}

{/if}

{if $count > 0}
	<ul class="sf-menu">
	{foreach from=$nodelist item=node}
		{if $node->depth > $node->prevdepth}
			{assign var='submenu' value="submenu"|cat:$node->depth-1}

			{repeat string="<ul class='$submenu'>" 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->parent == true or $node->current == true}
			{assign var='classes' value='selected'}
			{if $node->parent == true}
				{assign var='classes' value='selected menuparent'}
			{/if}
			{if $node->children_exist == true and $node->depth < $number_of_levels}
				{assign var='classes' value=$classes|cat:' parent'}
			{/if}
			<li><a class="{$classes}{if $node->id == $firstnode} first{elseif $node->id == $lastnode} last{/if}" href="{$node->url}">{$node->menutext}</a>

		{elseif $node->children_exist == true and $node->depth < $number_of_levels and $node->type != 'sectionheader' and $node->type != 'separator'}
			<li><a class="parent{if $node->id == $firstnode} first{elseif $node->id == $lastnode} last{/if}" href="{$node->url}">{$node->menutext}</a>

	
		{elseif $node->current == true}
			<li class="selected{if $node->id == $firstnode} first{elseif $node->id == $lastnode} last{/if}"><h3>{$node->menutext}</h3>

		{elseif $node->type == 'sectionheader'}
			<li><a class="sectionheader {if $node->id == $firstnode}first{elseif $node->id == $lastnode}last{/if}" href="#">{$node->menutext}</a>

		{elseif $node->type == 'separator'}
			<li class="separator{if $node->id == $firstnode} first{elseif $node->id == $lastnode} last{/if}" style="list-style-type: none;"> <hr />

		{else}
			<li><a href="{$node->url}" class="{if $node->id == $firstnode}first{elseif $node->id == $lastnode}last{/if}">{$node->menutext}</a>

		{/if}

	{/foreach}
	{repeat string="</li></ul>" times=$node->depth-1}</li>
	</ul>
{/if}
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1457
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: Smarty 3 change broke my nav (1.10 to 1.11)

Post by paulbaker »

Much fiddling around lead to the answer:

Code: Select all

{assign var='submenu' value="submenu"|cat:($node->depth-1)}
You have to put

Code: Select all

$node->depth-1
in brackets.

$node->depth is an INT by the way.

Every day's a school day.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
Post Reply

Return to “CMSMS Core”