Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to assign global scope variables #194

Closed
machavity opened this issue Feb 23, 2016 · 3 comments
Closed

Unable to assign global scope variables #194

machavity opened this issue Feb 23, 2016 · 3 comments

Comments

@machavity
Copy link

I'm running the latest from the repo pull and have run across a problem. It manifested itself in being unable to pull in a subtemplate. What was odd is that the path, which relies on an assigned global variable, was being assigned in another previous subtemplate. This assignment works fine in 3.1.17 but appears to no longer work in the current version of Smarty

SubTemplate 1
{assign var="product_template" value="$shareddir/Views/Product" scope="global"}

SubTemplate 2 (called after Template 1)
{$product_template}

Produces

Notice: Undefined index: product_template

If I assign it in each template it works... but this defeats the purpose

@uwetews
Copy link
Contributor

uwetews commented Feb 23, 2016

{assign var="product_template" value="$shareddir/Views/Product" scope="global" bubble_up}

for now,
but it will be reworked during the next couple of days for BC

read NEW_FEATURES.txt

@uwetews
Copy link
Contributor

uwetews commented Feb 23, 2016

Using global scopes is always dangerous as you may loose overview in complex template structures.

In your case the safest solution is

{assign var="product_template" value="$shareddir/Views/Product" scope="parent"}

It will assign the variable just in the calling template, so that it's know when Sub Template 2 is called.

All other variable scopes are not touched.

@uwetews
Copy link
Contributor

uwetews commented Mar 9, 2016

The fix is now in the master branch.

read the NEW_FEATURES.txt for details

@uwetews uwetews closed this as completed Mar 9, 2016
uwetews added a commit that referenced this issue Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants