Skip to main content
23 votes

Magento2 contact form in CMS page

Call your contact form block with template file in the cms pages. Try below code : {{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
Manthan Dave's user avatar
  • 9,886
19 votes
Accepted

Magento 2.2.2 how to check if current page is a CMS page in .phtml file?

There are no registry variable add at cms page. So, if you want to check a page is CMS page then you need to check current controller and action name means Full action name Best practices In ...
Amit Bera's user avatar
  • 77.6k
15 votes
Accepted

CMS Page URL from ID in phtml (M2)

By using object manager you can get CMS page url, if you have already id of cms page. $pageId = 1; $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); or $this->...
Chirag Prajapati's user avatar
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
15 votes
Accepted

How to create custom cms page layout file?

You can create a custom CMS page layout file by using this below way. File name should be like this : cms_page_view_selectable_<CMS Page Identifier>_<Layout Update Name>.xml => For eg : ...
Rohan Hapani's user avatar
  • 17.5k
12 votes
Accepted

Magento 2 - How to add or insert PDF file in a CMS page?

First, you need to add the files inside your project so magento can display them on the back office There is two ways : The simplier way : just add your file via ftp to media/wysiwyg/[...
Renaud's user avatar
  • 136
12 votes
Accepted

Magento 2: Get WYSIWYG editor's data in frontend?

Let's say the block that displays your content is called Vendor\Module\Block\Entity. Add a dependency Zend_Filter_Interface to your block like this: protected $templateProcessor; public function ...
Marius's user avatar
  • 198k
12 votes
Accepted

How to add custom link in main menu in Magento 2?

copy file from vendor/magento/module-theme/view/frontend/templates/html/topmenu.phtml and put this file in your theme location app/design/frontend/Vendor/YourTheme/Magento_Theme/templates/html/...
Suresh Chikani's user avatar
12 votes

How to add custom link in main menu in Magento 2?

Another alternative is to use a new template file via layout xml. ./app/design/frontend/Company/Yourtheme/Magento_Theme/layout/default.xml <?xml version="1.0"?> <!-- /** * Copyright info....
Dilhan Maduranga's user avatar
9 votes
Accepted

How to retrieve variable from CMS page in Magento 2

You can use in Magento 2 like this {{block class="Magento\Framework\View\Element\Template" name="blockname" template="Vendor_Module::test.phtml" my_vars="123,456"}} Now you can get the data by ...
Prince Patel's user avatar
  • 22.9k
9 votes
Accepted

Magento 2 : Add custom js to a single CMS page

You can do this by two ways as described below. First create the custom.js at below location (in your case you have already did this) app/design/{Vendor_name}/{theme}/web/js/custom.js Now you can ...
Abhishek Tripathi'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
  • 10.1k
8 votes
Accepted

How to exclude specific Products, Categories and CMS Pages from sitemap.xml generation in Magento 2?

Answer given a base on Magento 2.3.1 Opensource There are 3 files, the Sitemap related data of Products, Categories, and CMS Pages is coming Magento\Sitemap\Model\ResourceModel\Catalog\Category:...
Amit Bera's user avatar
  • 77.6k
7 votes
Accepted

Magento 2: How to Redirect from Observer to CMS Page

protected $responseFactory; protected $url; public function __construct( ... \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\UrlInterface $url ... ) { $...
Prince Patel's user avatar
  • 22.9k
7 votes
Accepted

Magento 2-How to link image to category page through cms page?

Please use below code for link in static page <a href="{{config path="web/unsecure/base_url"}}<<YOUR CATEGORY URL KEY>>" target="_self"><img src="{{media url="wysiwyg/clothing....
Aasim Goriya's user avatar
  • 5,454
7 votes

Where do I go to edit the CMS Home Page?

Magento 2 Edit CMS page to show go to Admin >> Contents >> CMS By default CMS page Admin >> Stores >> Configuration >> General >> Web >> Default Pages >> As u select CMS as a by default
HIren Kadivar's user avatar
7 votes

Magento 2.2.2 how to check if current page is a CMS page in .phtml file?

Try to use below code in your .phtml file <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $request = $objectManager->get('\Magento\Framework\App\Request\Http'); $...
Chander Shekhar's user avatar
6 votes
Accepted

How redirect the "no-route" cms page to home page after 10 second (not through server side)

you can add set setTimeout <script type="text/javascript"> function scr(){ window.location = "http://www.yoururl.com"; } setTimeout(scr,10000); </script>
Qaisar Satti's user avatar
  • 32.5k
6 votes

Magento CMS Page keep redirect to homepage

Open your admin panel of magento. Goto System>Configuration>>Web> URL Option and change Auto-redirect to Base URL to No.
Nikul's user avatar
  • 1,306
6 votes
Accepted

Where are pages and blocks created in the admin section stored?

Both in the database: blocks in cms_block table pages in cms_page table Please note that Magento also stores the relationship between those and the store ids in the following tables: ...
Raphael at Digital Pianism's user avatar
6 votes
Accepted

How to overide ui component form in magento 2?

Create Vendor/Module/view/adminhtml/ui_component/cms_page_form.xml <?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Sohel Rana's user avatar
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
Accepted

Magento2: How can update & create the CMS static Page programmatically

Here is an example how to insert cms data in m2 Here is an example how to update cms data in m2 Now you can try following way for insert cms data: public function __construct( \Magento\Cms\...
Sohel Rana's user avatar
6 votes
Accepted

Magento 2 - How to use jQuery in CMS page

You can try this : <script> require([ 'jquery' ], function ($) { $(".home-banner").insertBefore(".page-main"); }); </script>
Hitesh Koshti's user avatar
5 votes

Magento 2 Export & Import CMS Blocks and CMS Pages

You can use MSP/CmsImportExport. However the db tables involved are: cms_block cms_block_store cms_page cms_page_store
Lorenzo's user avatar
  • 648
5 votes

Magento2: How to add different custom css file on specific CMS pages

You can add Layout Update XML update GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML With the content : <head> <css src="Namespace_YourModule::...
Franck Garnier'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

add to cart button in CMS page

You are using Mage class, which has been removed in Magento 2. The Magento 2 equivalent of <?php echo Mage::helper('checkout/cart')->getAddUrl($product) ?> is as below: Method 1 <?php ...
Reena Parekh's user avatar
  • 1,927
5 votes

How to include module's CSS in CMS pages with module block

Put your js file in your custom module Vendor_Module/view/frontend/web/js/yourjsfile Create requirejs-config.js file in your custom_module/view/frontend. add below code in it . var config = { "...
Manthan Dave's user avatar
  • 9,886
5 votes

Magento2 contact form in CMS page

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
omelandr's user avatar
  • 1,267

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