Page 1 of 1

[SOLVED] Smarty scope of variables CMSMS after 1.12.1 -> 2.0

Posted: Sat Sep 26, 2015 10:19 pm
by pjb
It looks like I'm running into a Smarty scope of variables problem after a CMSMS 2.0 upgrade.

I've attached my template file, and the UDT {mobile} it calls.

It looks to me like the template, at line 5, is trying to capture the value of $mobile_detect, which appears to be assigned in line 150 of the UDT {mobile}:

$smarty->assign('mobile_detect',false);

But this isn't working.

The template relies on the value of $mobile_detect to trigger the display of page content, and that isn't happening. Though of course it did work in CMSMS 1.12.1.

I've tried using the {share_data} tag, but with no luck. Nor do I know how to make $mobile_detect assigned as global in scope.

For what it is worth, both the template and the UDT are from a site created with the Foundation 5 responsive framework. That is, I did not -- and could not -- write this from scratch.

Thanks for your help.

============


----------------------------------------------

Cms Version: 2.0

Installed Modules:

CMSMailer: 5.2.4
FileManager: 1.5
MenuManager: 1.50
ModuleManager: 2.0
News: 2.50
Printing: 1.1.1
Search: 1.50
ThemeManager: 1.1.8
TinyMCE: 2.9.12
FormBuilder: 0.8.1.1
Captcha: 0.5.2
FormBrowser: 0.4.2
AdminSearch: 1.0
MicroTiny: 2.0
CGExtensions: 1.49.7
JQueryTools: 1.3.7
CMSContentManager: 1.0
CMSFoundation: 1.5.1
CGSmartImage: 1.20.3
DesignManager: 1.0
Navigator: 1.0


Config Information:

php_memory_limit:
max_upload_size: 2000000
url_rewriting: none
page_extension:
query_var: page
auto_alias_content: true
locale:
set_names: true
timezone: America/Chicago
permissive_smarty: false


Php Information:

phpversion: 5.4.45
md5_function: On (True)
json_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_STRICT: 0
E_DEPRECATED: 0
test_file_timedifference:
test_db_timedifference:
memory_limit: 128M
max_execution_time: 30
output_buffering: 0
file_uploads: On (True)
post_max_size: 8M
upload_max_filesize: 2M
session_save_path: /tmp (1777)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)


Performance Information:

allow_browser_cache: Off (False)
browser_cache_expiry: 60
php_opcache: Off (False)
smarty_cache: Off (False)
smarty_compilecheck: Off (False)
smarty_cache_udt: Off (False)
auto_clear_cache_age: Off (False)

Server Information:

Server Api: cgi-fcgi
Server Db Type: MySQL (mysql)
Server Db Version: 5.5.40
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable
Server Time Diff: No file system time difference found


----------------------------------------------

Re: Smarty scope of variables problem after CMSMS 1.12.1 ->

Posted: Sat Sep 26, 2015 10:36 pm
by Jo Morg
Try replacing

Code: Select all

$smarty->assign(...
by

Code: Select all

$smarty->assignGlobal(...
There are at least 2 instances of assign so you should try to replace them both. Untested though...

Re: Smarty scope of variables problem after CMSMS 1.12.1 ->

Posted: Thu Oct 01, 2015 12:13 pm
by pjb
Jo,

Replacing assign with assignGlobal provided the fix, though I ended up having to make that edit to a variable assignment in the page template as well as the UDT. Thanks for the prompt and useful help!!