Up and to this point we’ve briefly seen the l.settings structure and that it’s used to allow local variable to output to the page template. Let’s dive in a bit deeper to understand more about the l.settings structure.
You can think of the l.settings structure as a special holding area. Any variables assigned to that structure automatically become available in the page template language. When a module developer wishes to make their variables available so you can use them in the page template to output or to test against, they simply need to add their variables into an l.settings structure. When Miva Merchant loads a page the l.settings structure has initialized with all the variables that are in the page template. If we look at the example here, the l.settings structure has two members; store and page. Now, in reality it actually has a lot more than that, but so we can visualize it, let’s pretend it just has these two. So the store structure contains variables for code, city, currency and phone. These are the variables that are defined in the Miva Merchant Admin under Store Settings.
Page is information about the page that was rendered. Here we have page code, page id, and page name. Because all these variables are part of the l.settings structure, they automatically become available within the page template. An l.settings variable acts very similar to a global variable. It’s available anywhere within the page template. You can output it to the screen using the path to the variable. For example, if i wanted to output the store code it would be &mvt:store:code; - there’s no prefix. Now, if we want to output these variables to the page, we can do that by using &mvt: and then the path to the variable. So :store would reference the store structure. Then :code which references the code. The same thing for page. &mvt:page:name; and this will output that value to the page.
Now, if you remember global variables, they had a prefix of global right after the &mvt. For local variables and for the l.settings variable you don’t need anything. Miva automatically knows you’re talking about the l.settings structure because it’s the only local structure that is available in the page template language. When we want to conditionally check a variable that’s part of the l.settings structure we’re going to reference it “l.settings:page:code” a full path to the variable. Here we’re saying if l.settings:page:code is EQ to SFNT the l.settings structure is a very important part of the Miva Merchant template language. It’s used quite a bit throughout all our page templates. You’ll see it over and over again. Once you understand how it works, it will make reading and understanding the Miva Merchant template language much easier.