I have {$issidebar = "0" scope=global} in a news template, but within the main template, it ignores it, and defaults to the one in the main template ... {$issidebar = "{content_module module="ECB2" field="checkbox" block="issidebar" label="Use Sidebar?" default_value="0" tab="Sidebar"}" scope=global}
I can confirm that {$content = "{content}" scope=global} is used after the $issidebar, therefore the news template should override the main template one, but doesn't ... it worked in v2.1x branch.
Are scopes broken in CMS 2.2 ?
Re: Are scopes broken in CMS 2.2 ?
Changing scope from "global" to "root" fixed it????
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Are scopes broken in CMS 2.2 ? [edited]
Scopes are not broken in 2.2. If anything the problem is less complex now before than it was [grammar correction].
I just tested again, and it works fine.
In 2.2 not only are we using a new version of smarty, but we now do what we call 'mact pre-processing'.... so if any request is primarily for a module action (such as a News detail view) it is passed through smarty first, before the page template is even processed.
So...
My news detail template has:
my page template looks like (simplified)
And, yes... when I visit a news detail view that uses that detail template, I get the H1 with the page title, the H2 with the WOOT message, and then the News detail view. As I would expect.
In conclusion: Scoping has not changed, setting global variables works fine. It's even simpler than before. Perhaps it's something weird in your templates that you would have to narrow down and identify.
Addendum:
a: This MAY effect some sites that are trying to pass data IN to module action templates (such as News detail templates) to adjust behavior in those templates.
This is generally considered to be a bad idea. Instead, you should use multiple different templates, and/or template inheritance.
b: There is a config setting to disable this behavior. Read about it at: https://docs.cmsmadesimple.org/configur ... -reference
I just tested again, and it works fine.
In 2.2 not only are we using a new version of smarty, but we now do what we call 'mact pre-processing'.... so if any request is primarily for a module action (such as a News detail view) it is passed through smarty first, before the page template is even processed.
So...
My news detail template has:
Code: Select all
{$testing=1 scope="global"}
Code: Select all
{process_pagedata}
<__html>
<head>
<title>{title}</title>
</head>
</__body>
<div class="sidebar">
{news limit=3}
</div>
<div class="main">
<h1>{title}</title>
{if !empty($testing)}<h2>Woot, global variable worked</h2>{/if}
{content}{* note, not usng any funky mechanism to assign content at the top. It will still work, but it is not necessary any more *}
</div>
<__body>
</__html>
In conclusion: Scoping has not changed, setting global variables works fine. It's even simpler than before. Perhaps it's something weird in your templates that you would have to narrow down and identify.
Addendum:
a: This MAY effect some sites that are trying to pass data IN to module action templates (such as News detail templates) to adjust behavior in those templates.
This is generally considered to be a bad idea. Instead, you should use multiple different templates, and/or template inheritance.
b: There is a config setting to disable this behavior. Read about it at: https://docs.cmsmadesimple.org/configur ... -reference
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.
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.
- Rolf
- Dev Team Member
- Posts: 7825
- Joined: Wed Apr 23, 2008 7:53 am
- Location: The Netherlands
- Contact:
Re: Are scopes broken in CMS 2.2 ?
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -