Problems with OR - AND in navigation after upgrade to 2.2.1

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
raiyul
Forum Members
Forum Members
Posts: 14
Joined: Sat Jul 08, 2017 1:10 pm

Problems with OR - AND in navigation after upgrade to 2.2.1

Post by raiyul »

On a page I had this code :

Code: Select all

{if feu_smarty::is_user_memberof('Auteurs,Membres,potentiel')}
I choose this page page
 {Navigator template="nautres.tpl"}
{else}
You must be member
 {/if}
and the content of template nautres.tpl was

Code: Select all

{if !isset($depth)}{$depth=0}{/if}
{if isset($nodes)}{strip}
<ul style="list-style-type:none; ">
{foreach $nodes as $node} 
{if ($node->extra1 == 'retour' ) or ($node->extra1== 'annonce') or 
(   ($node->extra1=='membres'and feu_smarty::is_user_memberof('Membres')) or
    ($node->extra1=='auteurs'and feu_smarty::is_user_memberof('Auteurs'))or 
    ($node->extra1=='attente'and feu_smarty::is_user_memberof('potentiel'))
	 )}
  {if $node->current}
  <li><a href="{$node->url}" class="currentpage"{if $node->target ne ""} target="{$node->target}"{/if}> {$node->menutext} </a>
  {else}
  <li><a href="{$node->url}">{$node->menutext}</a></li>
  {/if}
{/if}
{/foreach}
</ul>
{/strip}{/if}
After upgrade from 2.1.5 to 2.2.1 open this page gave this error :
Syntax error in template "module_file_tpl:module_file_tpl:Navigator;nautres.tpl" on line 19 "( ($node->extra1=='membres'and feu_smarty::is_user_memberof('Membres')) or" - Unexpected "and"
I could remove all AND by using more IF conditions and it was OK for this page.
But I had a new error in a gabarit with the code :

Code: Select all

{menu template="autres.tpl"}
and the content of template autres.tpl was

Code: Select all

<ul style="list-style-type:none; ">
{foreach from=$nodelist item=node} 
{if ($node->extra1 == 'retour' ) or ($node->extra1== 'annonce') or 
(  ($ccuser->loggedin())and 
   (($node->extra1=='membres'and feu_smarty::is_user_memberof('Membres')) or
    ($node->extra1=='auteurs'and feu_smarty::is_user_memberof('Auteurs'))or 
    ($node->extra1=='attente'and feu_smarty::is_user_memberof('potentiel'))
	))}
  {if $node->current == true}
  <li><a href="{$node->url}" class="currentpage"{if $node->target ne ""} target="{$node->target}"{/if}> {$node->Syntax error in template "module_file_tpl:module_file_tpl:MenuManager;autres.tpl"  on line 4 "(  ($ccuser->loggedin())and"  - Unexpected "and"
menutext} </a>
  {else}
  <li><a href="{$node->url}">{$node->menutext}</a></li>
  {/if}
{/if}
{/foreach}
</ul>
and here, came this error explanation :
Syntax error in template "module_file_tpl:module_file_tpl:MenuManager;autres.tpl" on line 4 "( ($ccuser->loggedin())and" - Unexpected "and"
At this point, I changed all AND in && and all OR in || and since I made these changes in both templates, my site runs perfectly.

I presume that navigation with templates containing so much AND - OR are harder to compile than with && - || instead.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Problems with OR - AND in navigation after upgrade to 2.

Post by calguy1000 »

CMSMS 2.2 introduced a newer version of smarty that probably has tougher parsing rules.

The words 'or' and 'and' are permitted operators in exchange for '||' and '&&' respectively. I think the problem you are having here is with whitespace. The lexer/parser is probably having a problem understanding that the 'or' is intended as an operator. I would add whitespace around all of your comparison operators.

Code: Select all

($node->extra1=='auteurs'and feu_smarty::is_user_memberof('Auteurs'))or
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
raiyul
Forum Members
Forum Members
Posts: 14
Joined: Sat Jul 08, 2017 1:10 pm

Re: Problems with OR - AND in navigation after upgrade to 2.

Post by raiyul »

With whitespace around all of your comparison operators it's OK.
Many thanks for the answer
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Problems with OR - AND in navigation after upgrade to 2.

Post by calguy1000 »

As an added note: FEU can take care of 90% of that automatically now.

Change the content type to 'Protected content' and then set the allowed group(s) when editing the page.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “[locked] Installation, Setup and Upgrade”