We can convert CMS page content into HTML specific format using native Magento class.
We need to use, \Magento\Cms\Model\Template\FilterProvider class to filter page content in the template file.
In PHP file,
<?php public function __construct( \Magento\Cms\Model\Template\FilterProvider $filter ) { $this->filter = $filter; } /* * Page content $content */ public function getContentFromPage($content) { return $this->filter->getPageFilter()->filter($content); }
Call from template file,
$content = "YOUR_CMS_PAGE_CONTENT"; echo $this->getContentFromPage($content);
Hello Rakesh,
Thanks for this, I need your help in cms pages/block content copy. I copied cms page/block by programmatically but when I open my cms page/block then I got https://prnt.sc/l0p1f8
But my actual content is https://prnt.sc/l0p1l2
How can I do this.
Hello Rakesh,
Thanks for this, I need your help in cms pages/block content copy. I copied cms page/block by programmatically but when I open my cms page/block then I got https://prnt.sc/l0p1f8
But my actual content is https://prnt.sc/l0p1l2
How can I do this.