With a big catalog of 224+ extensions for your online store
How to Insert a Widget into Sidebar in Magento 2
Magento 2 provides an XML Widget file that allows you to manage the page layout as well as place CMS Blocks at any position on the page. Widget can vary from buttons, dialog box, to search box, clock, or visitor counter. Displaying a Widget in the sidebar on your site will help provide more information and increase conversion rates. In the tutorial today, I will instruct you how to insert a Widget into Sidebar with two elements: “Configure a Widget” and “Configure a Layout Update”.
Steps to Insert a Widget into Sidebar in Magento 2
Configure a Widget
Widget is the awesome functionality you can insert to the CMS page from Magento 2 Configuration because it can be considered as a predefined set of configuration options. In the widget, you can add links that navigate directly to any content page, category, or product as you need.
Step 1: Select the Type
- On the Panel Admin,
Content > Elements > Widgets
. - In the upper-right corner of Widgets workplace, click on
Add New Widget
button. - In the Settings section:
- Choose CMS Static Block type in the
Type
box. - Choose the current theme you are applying in the
Design Theme
. - Click the
Continue
button.
- Choose CMS Static Block type in the
- In the Storefront Properties section,
- Enter
Widget Title
for the internal reference. - Assign the block to all store views in the
Assign to Store View
field or to any store view you want to apply the block. - Set the
Sort Order
if many blocks are placed at the same container. The block is at the top if the inserted value is zero.
- Enter
Step 2: Complete the Layout Updates
- In the Layout Updates section, click on
Layout Update
to set the layout.
Step 3: Place the Block
- Continue to select the
Widget Options
tab on the left panel. - Click on
Select Block
to choose the block from the list you want to place. - Click
Save
to complete. - Remember to flush the cache by getting the Cache Management link in the system message at the top of the workplace.
- Go to your storefront to check the position of the block. If you want to move the block, back to the widget settings and try a different page or block reference.
Configure a Layout Update
To insert the widget into the sidebar, you need to make a layout update to the XML code by changing lightly in the code. Due to that, it is simple to place the CMS Block Static on the right or left sidebar even or at different positions on the page.
- On the Admin Panel,
Content > Elements > Blocks
. - In the list of blocks, select the block you want to place, and then modify the
Identifier
. - On the Admin Panel,
Content > Elements > Pages
. - Choose the page where you want to place the block, then open the edit mode.
-
On the left panel, select the Design tab, in the
Layout Update XML
box, insert the code for the right or left sidebar.Code for CMS Block in Sidebar
<reference name="right"> <block type="cms/block" name="right.permanent.callout"> <action method="setBlockId"><block_id>your-block-id</block_ id></action> </block> </reference>
- Change the reference name to identify either the “right” or “left” column, according to the layout of the page.
- Change the block_id to the identifier of the block that is being placed.
Save Page
to complete.
Now you’re done with the widget insert process in Magento 2. Start creating your own now to communicate with customers more effectively. In case you have any questions, feel free to write in the comment box. There are also other widget posts for you to check out below.
Related Post
Looking for Magento Development Company?
8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.
Get free consultantRecent Tutorials
How to insert Order Attributes to Transactional Emails
How to insert Order Attributes to Transactional Emails
How to add Order Attributes to PDF Order Template
Explore Our Products:
People also searched for
- insert widget magento 2
- add a widget in magento 2
- how to display category in left sidebar in magento 2
- magento 2 sidebar
- magento 2 add widget to layout
- widgets in magento 2
- widget in magento 2
- magento 2 add widget to cms page
- magento 2 sidebar additional
- magento 2 add block to sidebar
- magento 2 sidebar category navigation
- magento 2 call widget in phtml
- magento 2 sidebar menu
- magento 2 widget
- magento 2 widgets
- what is widget in magento 2
- magento 2 show categories on left sidebar on a page
- magento sidebar
- widget magento 2
- widgets magento 2
- insert a widget magento 2
- layout update xml magento 2
- 2.3.x, 2.4.x
Stay in the know
Get special offers on the latest news from Mageplaza.
Earn $10 in reward now!