Skip to main content
26 votes
Accepted

How to add a CMS block programmatically in Magento 2?

add this to the your class: private $blockFactory; and make your constructor look like this: public function __construct( PageFactory $pageFactory, \Magento\Cms\Model\BlockFactory $...
Marius's user avatar
  • 198k
23 votes

Why do we have to use "store" for links in CMS like <a href="{{store url='home'}}">home</a>

As explained in Where is the code for "{{store url="example/example"}} {{store}} is one of the so-called template directives used by CMS and transactional emails It is documented as ...
Fabian Schmengler's user avatar
15 votes

How to add a CMS block programmatically in Magento 2?

You can try the following solution: Add 2 classes to the constructor: /** * @var \Magento\Cms\Model\BlockFactory */ protected $blockFactory; /** * @var \Magento\Cms\Model\BlockRepository */ ...
Mageworx's user avatar
  • 3,566
15 votes
Accepted

Magento 2 : Add Hero Image Upload Field on CMS page

First you have to create your own module to override the save action and dataProvider for cms page. If you don't know how to create module Please refer this link http://inchoo.net/magento-2/how-to-...
Nabin Maharjan's user avatar
13 votes

Magento 2 - upload SVG files

If you wan't change core files add this to di.xml of your module <type name="Magento\Cms\Model\Wysiwyg\Images\Storage"> <arguments> <argument name="extensions" xsi:type="...
Dmitry's user avatar
  • 379
12 votes

CMS and Block content warning Magento 2.4.2

I experienced this error too this morning and I dug a little : Magento\Cms\Model\Wysiwyg\Validator is responsible of this notification. ATM, it seems that it just shoot a message with no repercussion. ...
rou6e's user avatar
  • 1,041
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,522
9 votes
Accepted

Change page title via local.xml

Unfortunately, Magento does not support page specific handles for CMS pages. You can only change title for all CMS pages via local.xml which is not what you want. I suggest you use the backend when ...
Raphael at Digital Pianism's user avatar
9 votes
Accepted

Magento 2 how to get all cms pages in system configuration

You need to use the Magento\Cms\Model\Config\Source\Page source model. So replace: <source_model>Namespace\Module\Model\Test</source_model> With: <source_model>Magento\Cms\Model\...
Raphael at Digital Pianism's user avatar
9 votes

CMS and Block content warning Magento 2.4.2

I have fixed this issue for magento community version 2.4.3. You need to create a custom module Create registration.php file, Vendor/Module/registration.php <?php /** * Copyright ©2021 s All ...
Dipak Prajapati's user avatar
8 votes
Accepted

How to add custom error pages in Magento 2?

you can customize (404) page from admin Content->Pages->404 Not Found->Edit->content here you can change whatever content you need. If you look programmatically solution, add the below ...
Bilal Usean'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

How to add css sheet to the homepage only?

Typo mistake there. Change app/design/frontend/name/example/Magento_CMS/layout/cms_index_index.xml To app/design/frontend/name/example/Magento_Cms/layout/cms_index_index.xml I do have the ...
Raul Sanchez's user avatar
  • 3,145
6 votes

Add block from custom module to CMS page not working

As Piyush said it's likely you need to whitelist your block type. Navigate to System > Permissions > (Blocks | Variables) and whitelist your block type. Clear caches and see if it now works.
Ben Crook's user avatar
  • 15.7k
6 votes

How to add login form to homepage in Magento 2.1.9?

Please add below code to your layout update xml part of your home page in admin panel or in your cms_index_index.xml of your theme. <referenceContainer name="content"> <!-- customer....
Yogesh's user avatar
  • 1,523
6 votes

How to create a new page without using CMS?

You can achieve this by building a custom module. So our first step is to create a module folder and the necessary files required to register a Magento module. Create the following folders: app/code/...
codestr's user avatar
  • 515
5 votes

How to call an phtml file in CMS page in Magento 2?

{{block class="Magento\Framework\View\Element\Template" template="Magento_Cms::homepage/homepage-carousel.phtml"}} Replacing the class (if necessary) and template with the ones you need.
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

Forgot username and password after installing magento cms on my local server xampp

you can change password form phpmyadmin easily open phpmyadmin -> select your database -> select table "admin_user" edit first record and change user name or password (MD5 select )
Surendra Kumar Ahir's user avatar
5 votes

magento 2: display cms static page content in phtml file

Add following code in your Block class, here Form class is an example <?php namespace Vendor\Module\Block; class Form extends \Magento\Framework\View\Element\Template { /** * @var \...
Sohel Rana's user avatar
5 votes
Accepted

Magestore's Banner Slider not working properly(Magento 1.9)

It may be permission issue only. You need to give permission from admin to your block bannerslider/bannerslider Go to Admin -> System -> Permission -> Blocks Add New Block and add block ...
Ashish Jagnani's user avatar
5 votes
Accepted

Bluefoot cms for magento 2

At Imagine there was a roadmap revealed to state that Bluefoot would be integrated into Magento 2.3 - but in the meantime (& in case that timeline slips) the only way to get it is through an ...
amelvin's user avatar
  • 170
5 votes
Accepted

Magento 2 : Check Static Block with same identifier in InstallData Script

We can try: $cmsBlock = $this->blockInterfaceFactory->create(); $copyrightBlock = $cmsBlock->load('copy-right','identifier'); //And then check if (!$copyrightBlock->getId()) { ...... } ...
Khoa TruongDinh's user avatar
5 votes

There was no Home CMS page configured or found magento 2.1.7

Check if the page that you choose for the home page have the store view included in the option PAGE IN WEBSITE. Content > Pages> Home(or the name of your home page) > Edit > Page in website
Pasquale Perrone's user avatar
5 votes
Accepted

Invalid Blocktype

Verify the module is enabled in app/etc/modules and in System/Configuration/Advanced You did the permissions change {{block type="atwix_cmsattr/list" template="atwix/cmsattr/list.phtml"}} That should ...
Herve Tribouilloy's user avatar
4 votes

Adding CSS to a CMS page using Layout Update XML

If you want to add the specific CSS only for a CMS page and not for all CMS page : You can add Layout Update XML update for your CMS page here: admin ->CMS -> Pages -> Design -> XML Layout Update ...
Franck Garnier's user avatar
4 votes

Magento 2 - How to create FAQ page with accordion

This works for me : <div data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "multipleCollapsible": false}}'> <div data-role="collapsible"> ...
Laurent Khoudja's user avatar
4 votes

Forgot username and password after installing magento cms on my local server xampp

This process works in Magento 1.9 In order to change a preexistent administrator's password from the command-line, for SSH connections, you must open the /app/etc/local.xml to recover the connection ...
fmmarques's user avatar
  • 141
4 votes

Magento 2 - How to create FAQ page with accordion

I think you are having an issue with data-mage-init when saving or edit the content of the CMS page back. You can use accordion in CMS page by adding accordion js to your custom theme. Add accordion ...
Vikram Kumar's user avatar
4 votes
Accepted

Recently viewed widget display nothing - Magento 2.0.8

while you using this code {{widget type="Magento\Reports\Block\Product\Widget\Viewed" page_size="5" template="widget/viewed/content/viewed_grid.phtml"}} or insert widget in static block with code ...
Amin Shaker's user avatar

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