Get Free Audit

How to Use CMS Blocks in Magento

Feb 15, 2018

7787 Andrey Litvin

How to Use CMS Blocks in Magento

We keep on discussing Magento 1.9 features, so today’s article is dedicated to CMS blocks. We teach you how to create and insert CMS blocks and show the number of variables that can be used in blocks. If you have any suggestions, please, comment on below.

Create and insert CMS blocks

In order to create CMS blocks, you need to go to CMS/Static Blocks in the admin panel and there insert a necessary block, for example, like this:

CMS Blocks in Magento 1.9_1

1. For adding to an XML file, we should use the following construction:


2. Besides, one can add to WYSIWYG editor, for example, on the homepage. But before you need to add our type of blocks as allowed to System/Permissions/Blocks. So click on “Add new block” and fill in the fields, as it’s shown in the picture:

CMS Blocks in Magento 1.9_2

Then insert, for example, on the home page, so the code will be like that:


3. One more way means adding a CMS block to PHP file using the construction:


Magento Audit

Take your online store to the next level with BelVG Magento Audit

Visit the page

Understand the use of CMS template directives (var, store, block, …)

Let’s consider some variables that deserve more attention: skin, media, htmlescape, store, block, layout, config, customvar, protocol, widget.

1. skin
It’s used to output images from the skin folder and written with the following construction:


Moreover, there are attributes for the construction:

url – the pathname to the image without the vendor and theme name folder included.
_theme – the name of the theme.
_package – the name of theme producer.
_area – area name (frontend, adminhtml).

2. media
It’s used to output images from the media folder and written with the following construction:


Here is the only attribute which sets the pathname to the image in the rootsite/media folder.

3. htmlescape
It’s used to transform the html code into text and written with the following construction:

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


Andrey_Dubina

Partner With Us

Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

The construction also has its attributes:

var – here we add html.
allowed_tags – the argument is used for selecting the allowed tags from html.

4. store
It’s used to output urls using the following construction:


There are some attributes:

url – the path of the relative link in the website root.
_query_your parameter – adding the query parameter. For example,  if used _query_year=2018, ?year=2018 will be added to the link.
custom – adding one more parameter to the link. For example,



5. block
It’s used to output static blocks or a specific template. For example,


There are following attributes:

id – the code of the static block, for example, here link_main is used.
type – the type of the template.
template – the pathname to the template.

magento custom development

Magento Custom Development

Take your online store to the next level with BelVG Magento Custom Development

Visit the page

6. customvar
It’s used to output a variable which can be added to System→ Custom Variables.

CMS Blocks in Magento 1.9_3

Then we add the variable to the code


and see the code on the main page.

CMS Blocks in Magento 1.9_4

7. widget
It’s used to output widgets. As an example, let’s output the static block:


type – the type of widget.
template – the pathname to the widget template.

Thanks for reading!

With Layered Navigation extension for Magento you will be able to spread the navigation around and on top of the products on the page for easy and focused user navigation process.

dropdown_menu_1_1

Dropdown Menu

Take your online store to the next level with BelVG module

Download here
Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *