Each of the online stores are fond of these CMS blocks in Magento 2

10 February 2023

next article
Slava Nahnybida

PR manager

Slava Nahnybida
Each of the online stores are fond of these CMS blocks in Magento 2

If we analyze the abbreviation CMS literally, we will get "Content Management System". The key word here is “management”, so the more opportunities we have to do whatever we need with the content, the better CMS we chose. In this regard, Magento 2 is the undisputed world leader, as it provides so many useful features “out of the box” that most other systems can't even dream of. At the stage of creating an online store, this is mostly needed by developers: it is easier for them to implement all the wishes of the customer. But in the future, when the site is ready, all the advantages of Magento 2 will already be felt by the owners of the online store and the managers who work directly with the content of the site. Based on their own long-term practice, Avivi developers are convinced that if the necessary tools were provided at the development stage, in the future the client will ask for support much less often and will satisfy most of the functional needs on their own. So we are talking about exactly one of these topics right now.

Layout structure in Magento 2, blocks

Changing the structure of an online store page is one of the most popular types of tasks for technical support of eCommerce projects regardless of the CMS. Almost every week, numerous events occur that can become the causes of the necessary changes: changing seasons, approaching holidays, the spread of the latest trends, natural or man-made incidents, fluctuations in currency markets — anything, in a word. But it is not always possible to make changes quickly, which affects the profit from the online store. Therefore, flexible layout structure and easy template change is an important capability. In the first version of Magento, there were some difficulties with this, because the template for each of the layouts was defined in the corresponding .phtml files. But already in Magento 2, everything changed fundamentally with the start of using containers defined in layout XML files. The page structure is built on the containers. For example: header, footer, sidebar are all containers that can also contain nested containers or be empty. Site content is added to containers in the form of blocks — template files in which html code is generated.

schema.png

In Magento 2, the name “CMS blocks” is widely used, but this does not change the essence of the matter. Each block, like a container, has its own properties that allow you to perform many different operations with it (class, name, after/before, template, as, cacheable). A block can display any content provided by the template: text, image, video, etc.

Avivi developers can tell a lot about blocks: both about the stages of their life cycle, and about creation and rendering, and about adding Actions to blocks. But these topics are not too interesting for content managers, because for them the block is a universal tool for solving many issues. So let's stop on this topic.

Creation and management of CMS blocks

As you can see, blocks are an integral component of a Magento 2 website page, so they are used everywhere and always. The greatest value of the block is its ability to organically fit into the structure where it is needed. At the same time, each block is a self-sufficient unit that can be placed anywhere and adapted to the requirements of the container in which it is located. From the point of view of the frontend, it is extremely convenient and practical. As a result, the CMS helps its users to share the necessary information with the visitors of the online store exactly where this information is most relevant.

Until now, we have talked mostly about the appearance of the blocks. But managing them is no less interesting. In many other content management systems, this requires the help of a developer and the client can do almost nothing on his own. In Magento 2, managing blocks in the dashboard is as easy as managing the rest of the content, such as products, categories, orders, etc. Avivi developers do not in any way encourage you to deal with the CMS yourself, but we must inform you about this functionality, which will significantly facilitate the work of content managers.

magento-2-blocks.png

A list of all possible blocks is available in the Content menu item. In the same place, you can add new blocks and immediately customize them according to your needs. You can also fill the block with content right here using the usual Magento 2 visual editor. And if you prefer code, an html-editor is available too. An important option should be the place of display of the block: a specific container on the site page, header, footer, group of pages, etc. To place the block directly, use the Display Mode menu item.

Practical application of blocks in Magento 2

We made sure that the principle of building a page layout from containers and blocks is clear and practical. But a simple arrangement is far from all that CMS blocks offer to online store owners. Attributes allow you to develop your own scenarios and rules, according to which the block will appear on the site for a specific user at a precisely defined time. For example, if you are announcing the start of discounts, a simple block with a banner and text will suffice. But if the discounts are valid from 8 am till 4 pm, then thanks to a few lines of additional code, the block will appear only at a certain time.

Similarly, with free delivery for buyers who purchased goods for $500. In the process of filling the basket, the amount required to activate this service may appear in the block. For example: "43 dollars more and free delivery is yours!", when the basket contains $457 worth of goods. And there can be an unlimited number of such examples of custom scenarios for marketing or any other activity. Therefore, all that will be necessary for the content manager of your site is to select the desired CMS block from the list and determine the place of its display. Avivi developers will take care of everything else. Our team has extensive experience in developing Magento 2 projects to help your business thrive.


Similar articles
Apply for a consultation

We will reach out to within 10 minutes