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 ...
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"}}
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 ...
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 ...
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>
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"}}
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>
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="...
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.
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:...
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="...
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 ...
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>
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 ...
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 ...
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....
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 ...
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 ...
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>
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())->...
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')-&...
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\...
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
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="...
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-...
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') == ...
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')-...
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 ...
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;
}
...
......
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->...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
static-block × 467magento-1.9 × 130
magento2 × 106
cms × 50
blocks × 47
cms-block × 44
layout × 32
category × 30
phtml × 25
magento-2.1 × 19
cache × 16
php × 15
magento-1.7 × 14
magento-1.8 × 14
magento-1 × 14
template × 12
css × 12
widgets × 12
product × 11
cms-pages × 11
magento2.2 × 9
xml × 9
javascript × 8
frontend × 8
magento2.3 × 7