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,886
54 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
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.9k
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
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,542
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,168
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,886
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,807
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

Magento : disable cache for static block

that worked for me magento 1.9.2.3, tried for cms_menu cms block (file app/design/frontend/rwd/default/layout/cms.xml) <cms_menu> <reference name="left_first"> <block type="...
Konstantin Gerasimov's user avatar
4 votes
Accepted

How to show static block just below navigation?

The easiest way to add static blocks on Homepage and setting there order is: creating blocks and widgets You need to create a widget , name it discount bar select your static block ( discount-...
Manoj Deswal's user avatar
  • 5,805
4 votes

Proper method to get an attribute yes/no value so it is not translated

(put this in an answer because in a comment I've not enough space) I would do this test to check if the problem is in the blocks by removing the if ($_product->getAttributeText('colocation') == ...
Giuseppe's user avatar
  • 1,131
4 votes
Accepted

Injecting Variables into a Magento 2 CMS static block

I have created a sample code and its working fine for me: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $content = $objectManager->create('\Magento\Cms\Model\BlockFactory')-...
Sukumar Gorai's user avatar
4 votes
Accepted

Magento 2 decode widget code in category description

you need to pass the content of the description inside a function before the display. This filterProvider will replace the widget code inside the content of the description. public function ...
Taschert's user avatar
  • 569
4 votes
Accepted

Magento 2 How to update block programmatically?

You can try following way for insert/update CMS Block Content: public function __construct( \Magento\Cms\Model\BlockFactory $blockFactory ) { $this->blockFactory = $blockFactory; } ... ......
KKR's user avatar
  • 336
4 votes
Accepted

Get content of CMS Block in Magento 1.x

Use this code to echo content of cms block <?php foreach ($this->getAgreements() as $_a): ?> <?php echo Mage::helper('cms')->getPageTemplateProcessor()->filter($_a->...
Shoaib Munir's user avatar
  • 9,542

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