Page 1 of 1

lost in a maze around cgsimple::get_root_alias()...

Posted: Fri Sep 02, 2016 1:04 am
by dlen
Hello forists,

I just upgraded a site from cmsms 1.12.1 to 2.1.5.
I found out, that i had to replace
{$page_lang = substr($cgsimple->get_root_alias(),0,2)}
with
{$page_lang = substr($cgsimple::get_root_alias(),0,2)}

But this is not the end.

When I just cleared the cache, I get the following error message:

Code: Select all

ERROR: at line 176 in file /home/www/lib/smarty/sysplugins/smarty_internal_templatebase.php:
Invalid compiled template for 'tpl_top:2' 
and when I just hit 'reload' again, I get the following error message:

Code: Select all

parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /home/www/tmp/templates_c/ceb3b38b3d624997db99371a7a2661b864f38ed5.tpl_top.2.php on line 35
The line in question in the cache php-file is (whole file attached)

Code: Select all

$_smarty_tpl->tpl_vars['page_lang']->value = substr($_smarty_tpl->tpl_vars['cgsimple']->value::get_root_alias(),0,2); $_smarty_tpl->tpl_vars['page_lang']->nocache = null; $_smarty_tpl->tpl_vars['page_lang']->scope = 3;
I must admit, that I have no clue where to look further - thankful for any constructive remark.

Re: lost in a maze around cgsimple::get_root_alias()...

Posted: Fri Sep 02, 2016 7:01 am
by Rolf
Yesterday this came up in the IRC too, it maybe help you too. It should be documented in the module help.

Code: Select all

{$root=cgsimple::get_root_alias()}
Hope it helps

Re: lost in a maze around cgsimple::get_root_alias()...

Posted: Fri Sep 02, 2016 10:54 am
by dlen
Wow, it did help indeed. I was oviously using a "$" too many.

Apparently, within Smarty module names are not used with dollar-signs. Probably because the string is used "as is" to look up the object in the smarty parameter array. (Sorry, I am not in the "smarty zone" since a couple of month...these are all basics...)

Not so in an UDT. Here I have to use the "$" otherwise I get an error message already when trying to save. But I tried this:

Code: Select all

$smarty = cmsms() -> GetSmarty();
$cgsimple = $smarty->get_template_vars('cgsimple');
$root_alias = $cgsimple::get_root_alias();
and somehow $cgsimple isn't recognized properly, because i get

Code: Select all

Fatal error: Class name must be a valid object or a string in /home/www/lib/classes/class.usertagoperations.inc.php(278) : eval()'d code on line 5
Any hint welcome!

Re: lost in a maze around cgsimple::get_root_alias()...

Posted: Fri Sep 02, 2016 11:11 am
by Rolf

Re: lost in a maze around cgsimple::get_root_alias()...

Posted: Fri Sep 02, 2016 6:13 pm
by dlen
Thanks very much, I got this sorted out. Almost. Now struggeling with smarty scopes. But this will be another post, if any.

Re: lost in a maze around cgsimple::get_root_alias()...

Posted: Fri Sep 02, 2016 8:30 pm
by Rolf