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,
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?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,
1 2 | $content = "YOUR_CMS_PAGE_CONTENT"; echo $this->getContentFromPage($content); |