Magento Custom Variables

Magento provides an interface for you to define your own custom variables. You can use these in CMS pages, static blocks, email templates and phtml templates. Here’s how to use them.

Defining Custom Variables

You can add custom variables in the admin area. Go to ‘System > Custom Variables’.

For example, we’re going to create a custom variable to output a link to this blog. Fill in the fields as follows:

  • Variable Code: euperia_blog_link
  • Variable Name: Euperia Blog Link
  • Variable HTML Value: <a href="https://www.euperia.com">Visit euperia.com</a>
  • Variable Plain Value: Visit https://www.euperia.com

Defining Magento Custom Variables

Save this.

Using Custom Variables in CMS page and Static Blocks

To use our new custom variable in a CMS page or a static block we add the following markup:

Using Custom Variables in PHTML Templates

To use the custom variable in a phtml template we need to load it, specifically defining the HTML or Plain value: