4

I have created a custom block using Magento 2 UI, I know that I can't have any PHP in the block so I have created a test.phtml file and added it to my custom theme on the server.

Now, I want to call that block but can't figure out what path it will be.

The location of the test.phtml is following:

app/design/frontend/CustomTheme/CustomChild/Custom_Themesettings/templates/html/test.phtml

How should I call this test.phtml file in my block? I got something like this but it's not working:

{{block type="core/template" template="app/design/frontend/CustomTheme/CustomChild/Custom_Themesettings/templates/html/test.phtml"}}
9

File location will be

app/design/frontend/CustomTheme/CustomChild/Magento_Theme/templates/html/test.phtml

calling a block

{{block class="Magento\Framework\View\Element\Template" name="testblock" template="html/test.phtml"}}
1

I presume you mean a static block in the admin? If so try this:

{{block class="Magento\Framework\View\Element\Template" template="Custom_Themesettings::html/test.phtml"}}
0

Why Custom_Themesettings? if you want to add it in your theme use : app/design/frontend/{package}/{themename}/Magento_Theme/templates/html/test.phtml, if you have created a custom module put it : app/code/{Vendor}/{Modulename}/view/frontend/templates/html/test.phtml

To call the theme one :

{{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/test.phtml"}}

the module one :

{{block class="{Vendor}\{Modulename}\Block\{Blockname.php}" template="Vendor_Modulename::html/test.phtml"}}

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.