Are scopes broken in CMS 2.2 ?

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
kierweb
Forum Members
Forum Members
Posts: 41
Joined: Tue May 15, 2007 8:45 pm

Are scopes broken in CMS 2.2 ?

Post by kierweb »

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.
kierweb
Forum Members
Forum Members
Posts: 41
Joined: Tue May 15, 2007 8:45 pm

Re: Are scopes broken in CMS 2.2 ?

Post by kierweb »

Changing scope from "global" to "root" fixed it????
calguy1000
Support Guru
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]

Post by calguy1000 »

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:

Code: Select all

{$testing=1 scope="global"}
my page template looks like (simplified)

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>
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
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.
User avatar
Rolf
Dev Team Member
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 ?

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Locked

Return to “[locked] Installation, Setup and Upgrade”