0

I know many people have asked this question before, but I've tried every combination I can find and I'm not succeeding, so I need some advice in case I am missing something out.

I'm trying to add the contents of a PHTML file to a CMS Block in Magento (V2.2.1)

The theme is called Infortis/ultimo

/app/code/Infortis/Ultimo
/app/design/frontend/Infortis/ultimo

I've made a child theme Infortis-child/ultimo

/app/code/Infortis-child/Ultimo
/app/design/frontend/Infortis-child/ultimo

I've tried the following combinations in the CMS Block

{{block class="Magento\Framework\View\Element\Template" template="Infortis_ultimo::custombox.phtml"}}
{{block class="Magento\Framework\View\Element\Template" template="Infortis-child_ultimo::custombox.phtml"}}
{{block class="Magento\Framework\View\Element\Template" template="Vendor_customboxmaker::custombox.phtml"}}
{{block class="Magento\Framework\View\Element\Template" template="customboxmaker::custombox.phtml"}}

I've added the custombox.phtml to the following locations and none of them are loading the content into the CMS Block.

/vendor/customboxmaker/custombox.phtml
/app/design/frontend/Infortis-child/ultimo/custombox.phtml
/app/code/Infortis/Ultimo/view/frontend/templates/custombox.phtml
/vendor/customboxmaker/templates/custombox.phtml
/app/design/frontend/Infortis-child/ultimo/templates/custombox.phtml

Please can somebody confirm what I need to add to the CMS Block and the exact path location of the custombox.phtml file?

Do I need to add anything to the /app/design/Infortis-child/ultimo/etc/local.xml file as none of the examples I've found so far have indicated this is required?

Thank you

1 Answer 1

1

You are missing templates folder

/vendor/customboxmaker/templates/custombox.phtml

/app/design/frontend/Infortis-child/ultimo/templates/custombox.phtml

/app/code/Infortis/Ultimo/view/frontend/templates/custombox.phtml

You can call your template directly in cms block using

{{block class="Magento\Framework\View\Element\Template"  template="custombox.phtml"}}
8
  • I was really hoping that was it! It's still not loading though, I've copied the file to the 3 locations as per your post and the cms block entry. I have cache turned off too. Thank you so far
    – Chris
    Commented Dec 8, 2017 at 12:26
  • Have Deployed your content??
    – aravind
    Commented Dec 8, 2017 at 12:36
  • I havent deployed since I first installed it, could that be what I'm missing as I've added files? (php bin/magento setup:static-content:deploy)?
    – Chris
    Commented Dec 8, 2017 at 12:44
  • Yes u need to deploy conttents whenever crreating a module or creating nrew phtml
    – aravind
    Commented Dec 8, 2017 at 12:46
  • I've deployed, but oddly the templates folder and custombox.phtml file dont appear in /pub/static/frontend/Infortis-child/ultimo/en_US (or en_GB), the parent theme doesnt have the templates folder by default.
    – Chris
    Commented Dec 8, 2017 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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