Is this possible to load the cms page/ category inside custom phtml file, if it is possible how we can load cms page/ category inside custom phtml file.
Thanks.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIs this possible to load the cms page/ category inside custom phtml file, if it is possible how we can load cms page/ category inside custom phtml file.
Thanks.
Your phtml is rendered by a block class.
You need to add this in your block class.
protected $pageFactory;
protected $brandPage;
public function __construct(
....
\Magento\Cms\Model\PageFactory $pageFactory,
....
){
....
$this->pageFactory = $pageFactory;
....
}
public function getBrandsPageContent()
{
if (is_null($this->brandPage)) {
$this->brandPage = $this->pageFactory->create();
$this->brandPage->load('brand_list', 'identifier');
}
return $this->brandPage->getContent();
}
then in your phtml you just call echo $this->getBrandsPageContent()