How to create and use Default and Custom Variables

What are Variables?

 

Variables are reusable pieces of information that can be created once and used in multiple places, such as email templates, blocks, banners and content pages. Magento by default, includes a number of predefined variables that it pulls from the configuration (e.g. store name, store address).

 

How to add a predefined variable to a page

  1. Navigate to CMS > Pages > Manage Content,  search for and click into page you would like to add a variable to. 
  2. In the Page Information on the left hand side, select Content. Then, from the editor, do one of the following:
  • Click Insert Variable
  • or, if you prefer to work with html, click the Show / Hide Editor button.

3.  Click the Insert Variable button, to insert the variable where you would like to see it appear in the text. Find the required variable in the list, and once inserted, click the Save button.

 

How to create a custom variable

Creating custom variables does require a little basic HTML know-how, but can save time if you are finding inserting the same pieces of information time and time again. When a variable is inserted into HTML, it is formatted as a markup-tag, and enclosed in double curly braces (see below):

 

{{CustomVar code= "store_hours"}}

 

1. Navigate to System > Custom Variable, and then click the Add New Variable button

2. In the Variable Code field, enter an identified (must be all lowercase characters, without spaces).

3. Enter a Variable Name, (to be used for internal reference), and then do one of the following:

  • In the Variable HTML Value, enter any content you wish to include, using basic HTML tags
  • In the Variable Plain Value field, enter the variable value as plain text.

4. Once all is complete, click Save.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk