Page 1 of 1

Smarty 3 change broke my nav (1.10 to 1.11)

Posted: Thu Jun 10, 2021 5:38 pm
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 $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}
			{assign var='lastnode' value=$node->id}


{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}
		{elseif $node->index > 0}</li>

		{if $node->parent == true or $node->current == true}
			{assign var='classes' value='selected'}
			{if $node->parent == true}
				{assign var='classes' value='selected menuparent'}
			{if $node->children_exist == true and $node->depth < $number_of_levels}
				{assign var='classes' value=$classes|cat:' parent'}
			<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 />

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


	{repeat string="</li></ul>" times=$node->depth-1}</li>

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

Posted: Fri Jun 11, 2021 12:19 am
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

in brackets.

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

Every day's a school day.