Skip to main content
56 votes
Accepted

How to call static block in left sidebar in a page in Magento 2

If you want to call static block in page Try below code : {{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}} If you want to call in phtml file : Try below code : <?php ...
Manthan Dave's user avatar
  • 9,826
53 votes
Accepted

Magento 2 get base url (current store) in admin static block/page?

You can add current store URL in static block. {{store url=""}} If you wanto add store url with category URL. {{store url="category-url"}}
Suresh Chikani's user avatar
47 votes
Accepted

call static block in view.phtml insted of phtml file

You can use the below code: in .phtml file : <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml(); ?> sample : <?php echo $...
Qaisar Satti's user avatar
  • 32.5k
25 votes

Magento 2: Call phtml file in static block or cms page

You can use Magento\Framework\View\Element\Template class to call phtml files {{block class="Magento\Framework\View\Element\Template" template="Vendor_Module::myfiles/myfile.phtml"}} To call ...
Prince Patel's user avatar
  • 22.8k
24 votes

How to call a PHTML file within a CMS page Magento 2?

In magento,if you want to add block class in cms page, then you can tre below code {{block class="Magento\Bannerslider\Block\Slideshow" template="Magento_Bannerslider::bannerslider.phtml"}} Formula ...
Amit Bera's user avatar
  • 77.6k
17 votes
Accepted

Magento2 - Is it possible to get base url in a static block?

You can get base url in static block like this. <a href="{{store direct_url="business"}}">Your link</a>
Suresh Chikani's user avatar
15 votes
Accepted

Newsletter in Static Block Magento 2.1

You almost had it. Here's the code you need to use: {{block class="Magento\Newsletter\Block\Subscribe" name="static.newsletter" template="Magento_Newsletter::subscribe.phtml"}}
Raphael at Digital Pianism's user avatar
14 votes
Accepted

Call Custom phtml file in static block

You don't need to include the theme's directory in the template path, Magento will automatically use the current theme and fallback structure. For example: {{block type="core/template" template="page/...
Ben Crook's user avatar
  • 15.7k
11 votes

Magento 2 get base url (current store) in admin static block/page?

You can add store URL in static block: <a href="{{store direct_url='identifier'}}">Your link</a>
SIDDHANT JAIN's user avatar
11 votes
Accepted

Magento2: How to remove the newsletter block?

You can remove this block completely via layout with remove="true": app/design/frontend/TemplateMonster/Spiceli/Magento_Newsletter/layout/default.xml <?xml version="1.0"?> <page xmlns:xsi="...
Khoa TruongDinh's user avatar
11 votes
Accepted

store_url does not render link correctly

Add store direct_url instead of store_url <a href="{{store direct_url='produkte/insektenschutz/fenster/spannrahmen.html'}}"> spannrahmen.html will show after this.
Shoaib Munir's user avatar
  • 9,482
10 votes
Accepted

Using "Layout Update XML" to add a block to the sidebar

To reference a container you need to use referenceContainer as opposite to referenceBlock to reference a block. The container tag is used to create a container as the block tag is used to create a ...
Raphael at Digital Pianism's user avatar
9 votes

magento 2 : How to add static block in (.html) file?

To add static block over the Place order button!, you need to declare a PHTML file in checkout index anywhere in theme. STEP 1: Create a new XML file in theme checkout_index_index.xml <page xmlns:...
Chirag Jain's user avatar
8 votes

How to call static block in left sidebar in a page in Magento 2

This should work: <referenceContainer name="sidebar.additional"> <block class="Magento\Cms\Block\Block" name="yourblockid"> <arguments> <argument name="...
Arunendra's user avatar
  • 7,458
8 votes
Accepted

What am I doing wrong with this nested block

Instead of using getChildChildHtml('cookies.notice') Use getChildHtml('cookies.notice') We are usinggetChildChildHtml when we want to get 2nd level of child block For getting first level of child ...
Murtuza Zabuawala's user avatar
8 votes

store_url does not render link correctly

Try adding this to your block: <a href="{{store direct_url="produkte/insektenschutz/fenster/spannrahmen.html"}}">Link to Base URL</a>
HIren Kadivar's user avatar
7 votes
Accepted

Magento : disable cache for static block

Judging by your admin screenshot, is there any reason you are using two FPCs? Lesti_FPC and Evolved Caching? Normally only one FPC is needed, and judging by Evolved caching documents it has more ...
B00MER's user avatar
  • 8,307
7 votes
Accepted

get cms block title magento2

Out of the box you cannot retrieve the block title. What you'll have to do is: First, create your own block class that extends Magento\Cms\Block\Block Optional: if you want the getTitle method to ...
Raphael at Digital Pianism's user avatar
7 votes
Accepted

In magento 2 How to call phtml file in static block

{{block class="<vendor_name>\<module_name>\Block\<module_name>" name="<your_block_name>" template="<vendor_name>_<module_name>::<template_directory>/filename....
Jjo's user avatar
  • 1,158
6 votes

How to insert static block into header with local xml?

To do so add the following code to your local.xml file under the <default> handle: <reference name="header"> <block type="cms/block" name="my_block"> <action method="...
Raphael at Digital Pianism's user avatar
6 votes
Accepted

how to set Postion of static block on homepage?

You can set your xml like this, <block class="Magento\Customer\Block\Form\Newblock" name="customer.newblock" template="form/newblock.phtml" after="customer_form_login"/> Remove cache and check ...
Rakesh Jesadiya's user avatar
6 votes
Accepted

magento2: add static block to header menu

Firstly you need to create static cms block about us. and add your content in content part. Now to add that block in header follow the below steps : Create/Add new category from product/categories ...
Manthan Dave's user avatar
  • 9,826
6 votes

How to add a static block on all pages on Magento 2

If you want to call static block in page in magento 2 Try this below code : {{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}} If you want to call in phtml file : Try this ...
Randhir Yadav's user avatar
6 votes

What am I doing wrong with this nested block

Try getChildHtml rather than getChildChildHtml. Also use block_id rather than id: <action method="setBlockId"> <block_id>my_block</block_id> </action>
Ben Crook's user avatar
  • 15.7k
5 votes

CMS Block Cache issue with included dynamic template

In a phtml file, if you need to instantiate a block without cache you can use this: echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id')->setCacheKey(uniqid())->...
Iacob Daniel's user avatar
5 votes
Accepted

Display Static Block for a Customer Group

You can use below code to show static block for particular customer group if customer is logged In. /* Check if customer is logged in */ $isLoggedIn = Mage::getSingleton('customer/session')-&...
Kul's user avatar
  • 1,797
5 votes

Magento 2: Call phtml file in static block or cms page

The .phtml file location will be: /public_html/app/design/frontend/Emthemes/everything/shoppingcenter/templates/advanced/form.phtml And calling it on a block like this: {{block class="Magento\...
Nisha Jangid's user avatar
5 votes

How to remove extra divs in my Page Builder CMS blocks?

In page builder when creating CMS block add class=> ignore-div then add style for it .ignore-div {display: contents;} It will ignore wrapper
BeardMan's user avatar
4 votes

Config Path variables available in Static Blocks

Go to Admin->System->Permission->Variables and there add your config path first to access it in static block. Because after SUPEE 6788, there are restrictions to use all config paths.
Nauman Khan's user avatar
4 votes
Accepted

Magento2: Invalid block type

The attribute is called class, not type
Fabian Schmengler's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible