[Solved] Problem assigning scope=global var in Products

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am
Location: Sydney

[Solved] Problem assigning scope=global var in Products

Post by pwg »

Hi,

I am having a problem assigning variables in the latest Products module detail templates.

I am using {assign var='alt_title' value=$entry->product_name scope='global'} at the top of my detail template but don't seem to be able to set the page title.

Even printing variables reveals nothing.

I assume this has to do with scope='global' (http://forum.cmsmadesimple.org/viewtopi ... =7&t=73141

I did ask a variation of this querstion previously http://forum.cmsmadesimple.org/viewtopi ... =7&t=73335 but can now see i didn't know enough to actually ask the right question. Apologies if this have just been added to the previous question?

Cms Version: 1.12

Installed Modules:

CMSMailer: 5.2.2
CMSPrinting: 1.0.5
FileManager: 1.4.5
MenuManager: 1.8.6
MicroTiny: 1.2.9
ModuleManager: 1.5.8
News: 2.15.1
Search: 1.7.12
ThemeManager: 1.1.8
Gallery: 2.0.2
CGExtensions: 1.49.6
FormBuilder: 0.8.1.1
GBFilePicker: 1.3.3
ECB: 1.6
CGSimpleSmarty: 1.9.1
CGGoogleMaps2: 0.99.1
CGSmartImage: 1.20.2
JQueryTools: 1.3.6
CGBlog: 1.12.9
HitCounter: 2.0
Disqus: 2.0
AceEditor: 1.0
Products: 2.24.2
CGContentUtils: 1.5

Config Information:

php_memory_limit:
process_whole_template:
max_upload_size: 128000000
url_rewriting: mod_rewrite
page_extension:
query_var: page
image_manipulation_prog: GD
auto_alias_content: true
locale:
default_encoding: utf-8
admin_encoding: utf-8
set_names: true

Php Information:

phpversion: 5.5.28
md5_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_STRICT: 2048
E_DEPRECATED: 8192
memory_limit: 256M
max_execution_time: 300
output_buffering: 4096
safe_mode: Off (False)
file_uploads: On (True)
post_max_size: 128M
upload_max_filesize: 128M
session_save_path: /tmp (0700)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)

Server Information:

Server Api: litespeed
Server Db Type: MySQL (mysqli)
Server Db Version: 5.5.34
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable
Server Time Diff: No filesystem time difference found

Any advice appreciated,

Cheers,

Paul
Last edited by pwg on Thu Aug 27, 2015 11:33 pm, edited 1 time in total.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: Problem assigning scope=global var in Products

Post by Jeff »

Try printing the variables in various place to narrow down where it is going wrong.

Right after the assign (to make sure it is assign correctly)
At the bottom of the template it is assigned in (make sure something isn't over writing it)
Right after CMSms returns from the module call (in most cases this would be right after {content})
At the beginning of the <head> section.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Problem assigning scope=global var in Products

Post by calguy1000 »

This is actually due to a small bug in CMSMS and the way we use smarty.
It has been fixed in svn, and will be available in the upcoming 1.12.1 release.

In the mean time you can work around this issue by using some custom plugins to save variable data in a place 'other than smarty' and retrieve it.

The {session_put} plugin that comes with CGSimpleSmarty would handle it.

Code: Select all

{session_put var=page_title value=$entry->product_name}
then in your head section:

Code: Select all

{$page_title=$smarty.session.page_title|default:''}
{if $page_title != ''} ...{/if}
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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Problem assigning scope=global var in Products

Post by calguy1000 »

These two UDT's should be close to doing the same thing as the global assign:

udt: my_set

Code: Select all

$var = trim($params['var']);
$val = $params['value'];
if( $var )  \cms_utils::set_app_data('my_'.$var,$val);
usage: {my_set var=page_title value=$entry->product_name}

udt: my_get

Code: Select all

$var = trim($params['var']);
$assign = trim($params['assign']);
if( $var ) {
    $val = \cms_utils::get_app_data('my_'.$var);
    if( $assign ) {
       $smarty->assign($assign,$val);
    }  else {
       return $val;
    }
}
usage: {my_get var=page_title assign=page_title}{$page_title}
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.
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am
Location: Sydney

Re: Problem assigning scope=global var in Products

Post by pwg »

Fantastic, thanks so much for the replies.

Took me a moment to catch on that i would need to add the code ({my_set var=page_title value=$entry->product_name}) to the top section of every module detail template, for every variable i wanted, but once done, all good.

Really many thanks,

Cheers,

Paul
Locked

Return to “Modules/Add-Ons”