1

I have this file

app\design\frontend\company\mytheme\web\templates\header\foobar.phtml

How can I reference it in a layout file e.g. in

app\design\frontend\company\mytheme\Magento_Theme\layout\default.xml

e.g. to set it as a template for a block?

<referenceContainer name="header.container">
 <container name="header-wrapper" label="Page Header" as="header-wrapper" htmlTag="div" htmlClass="header content foobar">
 <block class="Magento\Theme\Block\Html\Header\Logo"
 name="logo" 
 template="Magento_Theme::foobar.phtml" <-- this does not work... how to make it right and set foobar.phtml as template ?
 >
 <arguments>
 <argument name="logo_img_width" xsi:type="number">189</argument>
 <argument name="logo_img_height" xsi:type="number">64</argument>
 </arguments>
 </block>
 </container>
</referenceContainer>

If I move foobar.phtml to app\design\frontend\company\mytheme\Magento_Theme\templates then it works, but how does it work from my themes web directory?

asked Dec 2, 2019 at 13:16

1 Answer 1

0

I solved it by creating a new folder named Company_Mytheme (Vendor_Themename) and moving foobar.phtml to

app\design\frontend\company\mytheme\Company_Mytheme\templates\foobar.phtml

Then I referenced it like this:

<referenceContainer name="header.container">
 <container name="header-wrapper" label="Page Header" as="header-wrapper" htmlTag="div" htmlClass="header content foobar">
 <block class="Magento\Theme\Block\Html\Header\Logo"
 name="logo" 
 template="Company_Mytheme::foobar.phtml"
 >
 <arguments>
 <argument name="logo_img_width" xsi:type="number">189</argument>
 <argument name="logo_img_height" xsi:type="number">64</argument>
 </arguments>
 </block>
 </container>
</referenceContainer>

You can name the folder anything you like, e.g. Foo_Bar, it will also work, you just have to make sure to use it in the layout

answered Dec 2, 2019 at 13:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.