- Magento 2 Theme Design(Second Edition)
- Fernando J Miguel Richard Carter
- 199字
- 2021-07-08 10:35:33
Custom Variables
Custom Variables are pieces of code that have specific values, like a programming variable. By creating a Custom Variable, you can apply it to multiple areas on your site. An example of Custom Variable structure is {{config path="web/unsecure/base_url"}}
. This variable shows the URL of the store.
Now let's create a Custom Variable to see how it works:
- Open your favorite browser and access the admin area,
http://localhost/packt/admin_packt
. - Navigate to System | Custom Variables.
- Click on the Add New Variable button.
- In the Variable Code field, enter the variable in lowercase and with no spaces, for example,
dev_name
. - Enter Variable Name, which explains the variable's purpose.
- Enter the Variable HTML Value and Variable Plain Value of the Custom Variable and save it.
Now we have a custom variable that stores the developer's name. Let's use this variable inside the CMS About Us page:
- In the admin area, navigate to Content | Pages.
- Click to edit the About Us item.
- Click on the Content side menu.
- Click on the Show / Hide Editor button to hide the HTML editor.
- Put the following code at the end of the content,
{{CustomVar code="dev_name"}}
, and save the content.

Let's check the result:

推薦閱讀
- Microsoft Exchange Server PowerShell Cookbook(Third Edition)
- GraphQL學習指南
- Java Web應用開發技術與案例教程(第2版)
- Magento 1.8 Development Cookbook
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Microsoft Azure Storage Essentials
- Elasticsearch Essentials
- Java程序設計與項目案例教程
- SQL Server 入門很輕松(微課超值版)
- Elastix Unified Communications Server Cookbook
- RESTful Web API Design with Node.js
- 精益軟件開發管理之道
- Building Microservices with Go
- C# 7 and .NET Core 2.0 Blueprints
- Python繪圖指南:分形與數據可視化(全彩)