2

I want to include the CMS Page in a phtml template. How can I achieve this? Can anyone help me over here?

  • Do you mean to show the contents of cms page in phtml? – Sukumar Gorai Jul 12 '18 at 9:08
  • yes i want to show the content of cms page content. – user3737063 Jul 12 '18 at 10:52
2

If you want to show the cms page content on your phtml page then write the following code:

Method 1(by page identifier):

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$content = $objectManager->create('\Magento\Cms\Model\PageFactory')->create();
$content->load('your-page-identifier', 'identifier');
echo $content->getContent();

Method 2(by page ID):

$page_id = YOUR_PAGE_ID;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$content = $objectManager->create('\Magento\Cms\Model\PageFactory')->create();
$content->load($page_id);
echo $content->getContent();
  • Can we get the sofware code and then if the code matches then only we need to show this page can we do this...? – user3737063 Jul 13 '18 at 6:41
  • What do you mean by software code? – Sukumar Gorai Jul 13 '18 at 7:15
  • I'm downloading the zip file when a link is clicked in CMS page content. And I wnat to hide content if the software id in null. how can we achive dis. – user3737063 Jul 13 '18 at 7:26
  • how do you get the software id? Can you add how do you get software id? – Sukumar Gorai Jul 13 '18 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.