- 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:

推薦閱讀
- Git Version Control Cookbook
- Learning Real-time Processing with Spark Streaming
- Python數(shù)據(jù)分析基礎(chǔ)
- Production Ready OpenStack:Recipes for Successful Environments
- 網(wǎng)店設(shè)計(jì)看這本就夠了
- AutoCAD VBA參數(shù)化繪圖程序開發(fā)與實(shí)戰(zhàn)編碼
- C語言程序設(shè)計(jì)案例精粹
- Protocol-Oriented Programming with Swift
- 愛上micro:bit
- 用戶體驗(yàn)可視化指南
- 深度學(xué)習(xí)原理與PyTorch實(shí)戰(zhàn)(第2版)
- IBM Cognos TM1 Developer's Certification guide
- Java多線程并發(fā)體系實(shí)戰(zhàn)(微課視頻版)
- 分布式數(shù)據(jù)庫HBase案例教程
- 零基礎(chǔ)學(xué)Java(第5版)