Hot answers tagged

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
21 votes

Magento 2 - How to create FAQ page with accordion

It is possible. If you want to use data-mage-init Then you do it like this: <div id="element" data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "...
iva's user avatar
  • 461
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,786
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

Add static cms block in home page

It is a late reply, but i will share. It is true that you can do it all from admin. You can add any static block to any cms page directly from admin as a widget. Open the CMS page and then click on ...
Altaf Hussain'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
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,394
11 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,021
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
8 votes
Accepted

Adding custom CSS / JavaScript to Certain CMS Pages With Custom JS Path

Try bellow way Add custom CSS or JavaScript to CMS Pages With Custom JS Path <reference name="head"> <action method="addItem"><type>skin_js</type><name>js/...
Abdul's user avatar
  • 9,702
8 votes
Accepted

Adding CSS to a CMS page using Layout Update XML

The solution I found was to create an XML file specifically called cms_index_index.xml. Inside that file I was able to simply call the css I needed <?xml version="1.0"?> <page xmlns:xsi="...
Gary's user avatar
  • 151
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
  • 9,947
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
8 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
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,276
6 votes
Accepted

Change list.phtml to show products of multiple categories in same block

Good question! The trick here is to extend a block based on catalog/product_list. I think the best way here is to add some xml to the "Layout Update XML" section. <reference name="content"> ...
Wouter Steenmeijer's user avatar
6 votes
Accepted

Product list by category in CMS page

For Magento 1.9.2.x, You need to create permission for 'catalog/product_list' block from 'System->Permissions->Blocks'
Sohel Rana's user avatar
  • 35.7k
6 votes

Magento EE 1.13 catalog routing

@benmarks answer is already good. But you will still have issues if your product URLs match your CMS page URLs. The URL rewrites from the table core_url_rewrite are checked before the routers are ...
Simon's user avatar
  • 5,725
6 votes
Accepted

Display products from specific category on CMS page

Assuming you are using 1.9.2.[23] or 1.9.2.[01] with security patch SUPEE-6788 applied, you will need to add the block to the allowed block whitelist. Go to System > Permissions > Blocks. Click ...
Peter O'Callaghan's user avatar
6 votes
Accepted

Getting at variables from CMS block insertions

You can definitely use the code you pasted: {{block type="core/template" template="page/html/jobappform.phtml" a="1" b="2"}} And then in your template you can do: $this->getA(); $this->getB()...
Raphael at Digital Pianism's user avatar
6 votes
Accepted

Magento 2 Replacement for cms/template Object

if I understand you correctly, you can do this with the Magento\Cms\Model\Template\FilterProvider if you want to "filter" a string with cms "objects" it should be working like this: return $this-&...
David Verholen's user avatar
6 votes
Accepted

Magento 1.9 - Store Hours of Operation not available for CMS

You need to go to System -> Permissions -> Variables and add new variable general/store_information/hours as allowed for it to work on frontend. As to why it is like this, I guess they just forgot ...
Anton's user avatar
  • 86
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,503
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
  • 495
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

CMS Block Cache issue with included dynamic template

I suspect that because I'm re-using the block dynamically that it will always have the same block id and therefore the fix will not work That's right. And by adding dynamic content to a static block ...
Fabian Schmengler'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

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