Smart syntax change after Upgrade

General project discussion. NOT for help questions.
Post Reply
musicscore
Power Poster
Power Poster
Posts: 470
Joined: Wed Jan 25, 2006 11:53 am
Location: Netherlands

Smart syntax change after Upgrade

Post 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 ?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1711
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Smart syntax change after Upgrade

Post 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)}
Not getting the answer you need? CMSMS support options
musicscore
Power Poster
Power Poster
Posts: 470
Joined: Wed Jan 25, 2006 11:53 am
Location: Netherlands

Re: Smart syntax change after Upgrade

Post 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.
Post Reply

Return to “General Discussion”