Page 1 of 1

Smart syntax change after Upgrade

Posted: Thu Sep 26, 2024 10:03 am
by musicscore
I noticed that after upgrading from CMSMS 2.2.15 to 2.2.21 I had to change a smarty syntax line.

In CMSMS 2.2.15 I was able to use :

Code: Select all

      {$children=cgsimple::get_children()} 
      {if count($children) > 0}
or

Code: Select all

      {$children=cgsimple::get_children()} 
      {if $children|count > 0}
But in CMSMS 2.2.21 this generated a 501 error

I had to change it to

Code: Select all

      {$children=cgsimple::get_children()} 
      {if cgsimple::has_children()}
I use this code to check if a page has children.

Is this a know change or was my initial syntax wrong ?

Re: Smart syntax change after Upgrade

Posted: Thu Sep 26, 2024 2:12 pm
by DIGI3
You should be able to do |count, but it's possible there's a bug in that module and it's not returning an array properly. Your PHP error log should give more clues.

CG modules were discontinued by their author a few years ago, so I'd suggest migrating to SmartyExt. I tested the following and they all worked (PHP 8.1):

Code: Select all

{smx::get_children() assign=kids}
{$kids|count}

Code: Select all

{$kids = smx::get_children()}
{$kids|count}

Code: Select all

{smx::get_children() assign=kids}
{count($kids)}

Re: Smart syntax change after Upgrade

Posted: Thu Sep 26, 2024 2:52 pm
by musicscore
Thanks DIGI3

Gonna test the change first in my test environment and will implement then in production environment.

Is indeed an older design using older modules.