We’re rewarding the question askers & reputations are being recalculated! Read more.
14

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"}}


11

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->_objectManager = $block->_objectManager; $CMSPageURL = $this->_objectManager->create('Magento\Cms\Helper\Page') ->getPageUrl($pageId); you can call ...


11

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-create-a-basic-module-in-magento-2/. After creating a module, follow the following steps: Step 1. Add column for custom image on cms_page table Create ...


9

you are getting that url because the homepage is a CMS page. In your case it has the identifier home. In order to change that url you need to rewrite the method Mage_Sitemap_Model_Resource_Cms_Page::_prepareObject and make it look like this: protected function _prepareObject(array $data) { $object = new Varien_Object(); $object->setId($data[$this-...


9

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/topmenu.phtml Add below <li> structure just after <?php /* @escapeNotVerified */ echo $block->getChildHtml(); ?> line in topmenu.phtml <li ...


8

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/[optional_folders]/[your_file.pdf]. OR Make magento allow pdf files upload on back office. There's two steps : Add pdf to allowed extensions type. With that modification ...


8

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 calling: $myVar = $block->getData('my_vars'); OR $myVar = $block->getMyVars(); Note: You should use $block instead of $this


8

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 Magento2, every block has request Object ,So you can get current page full action name via $block->getRequest()->getFullActionName(); Code: $...


7

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 __construct( ... \Zend_Filter_Interface $templateProcessor, ..... ) { .... $this->templateProcessor = $templateProcessor; .... } Then ...


6

you can add set setTimeout <script type="text/javascript"> function scr(){ window.location = "http://www.yoururl.com"; } setTimeout(scr,10000); </script>


6

Open your admin panel of magento. Goto System>Configuration>>Web> URL Option and change Auto-redirect to Base URL to No.


6

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 below code : <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?> Your xml ...


6

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\Model\PageFactory $pageFactory ) { $this->pageFactory = $pageFactory; } And now: $cmsPage = [ 'title' => 'TEST TITLE', 'identifier' => 'test-content-1'...


6

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.png"}}" alt="" width="IMGWIDTH" height="IMGHEIGHT" /></a> OR <a href="{{store url='YOUR CATEGORY URL KEY'}}" target="_self"><img src="{{...


6

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


6

Try to use below code in your .phtml file <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $request = $objectManager->get('\Magento\Framework\App\Request\Http'); $checkModule = $request->getModuleName(); if($checkModule == 'cms'){ echo "cms page"; }else{ echo "not cms page"; } ?>


6

You can create a custom CMS page layout file by using this below way. File name should be like this : cms_page_view_id_<your-custom-cms-page-identifier>.xml => For eg : If your cms page identifier is customhome, then file name should be cms_page_view_id_customhome.xml <?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights ...


5

You can use the following code in the content area of the CMS page: {{block type="core/template" template="mw/news/slider.phtml"}} If needed you can replace 'core/template' with another custom block type. You can't use a custom .phtml template when adding a widget, so inserting the block directly is the right way to do it.


5

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::css/styles.css"/> </head> Then there is a bug in Magento 2, you need to override the default Magento 2 vendor/magento/framework/View/Layout/etc/...


5

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 \Magento\Cms\Model\Template\FilterProvider */ protected $_filterProvider; /** * @var \Magento\Cms\Model\Page */ protected $_page; /** ...


5

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 = { "map": { "*": { "instapic": "Vendor_Module/js/instapic-slider" } } }; Now call the js file in your .phtml template file by ...


5

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}


5

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:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <fieldset name="general"> <field name="identifier_test"> <argument ...


5

protected $responseFactory; protected $url; public function __construct( ... \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\UrlInterface $url ... ) { $this->responseFactory = $responseFactory; $this->redirect = $redirect; $this->url = $url; } public function execute(\Magento\Framework\Event\...


5

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 choose any of the below steps for your requirement. 1st Way Just traverse to the below location Admin > Content > Elements > Pages > Design > Layout ...


4

You are probably using the wrong reference. Only the Mage_Page_Block_Html_Breadcrumbs class has theaddCrumb method. Example: <reference name="breadcrumbs"> <action method="addCrumb"> <crumbName>Home</crumbName> <crumbInfo> <label>Home</label> <title>Home</title>...


4

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: cms_block_store cms_page_store


4

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 echo $objectManager->get('Magento\Checkout\Helper\Cart')->getAddUrl($product) ?> Method 2: Also, Note that you should avoid using Object Manager in ...


4

add cache_lifetime="null" to every inclusion of this block. for example if you add block in CMS content: {{block type="cms/block" block_id="your_block_id" cache_lifetime="null"}} or if you add block in XML: <block type="cms/block" name="cms_footer_links" before="footer_links"> <action method="setBlockId"><block_id>...


4

Yes I got the solution for that: I have installed MageWorx SeoBase extension that extension adds two fields in the cms_page table: 1. meta_robots and 2. mageworx_hreflang_identifier but that field does not show on the content > page and both fields are set as nullable = false; that's why the page was not saving I just go the database, open the cms_page ...


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