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"}}
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 ...
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->...
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-...
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 : ...
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/[...
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 ...
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/...
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....
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 ...
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 ...
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 ...
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:...
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
...
) {
$...
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....
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
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');
$...
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>
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.
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:
...
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:...
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
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\...
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>
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
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::...
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 \...
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 ...
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 = {
"...
5
votes
Magento2 contact form in CMS page
{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
cms-pages × 300magento2 × 146
magento-1.9 × 54
cms × 52
cms-block × 33
magento-2.1 × 25
layout × 23
static-block × 11
blocks × 10
xml × 10
url-rewrite × 9
product × 8
redirect × 8
page-builder × 8
module × 7
javascript × 7
phtml × 7
page × 7
home-page × 7
magento2.3 × 6
magento2.2 × 6
css × 6
url × 6
magento2.4 × 6
magento-1.7 × 5