2

looking for some help. I have created a custom page with url:

http://localhost/magento2/hello_mvvm/hello/world

and here is a code from,

view/frontend/layout/hello_mvvm_hello_world.xml

code:

 <?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="content">
        <block
                template="content.phtml"
                class="Pulsestorm\HelloWorldMVVM\Block\Main"
                name="pulsestorm_helloworld_mvvm"/>
    </referenceBlock>
</page>

some how I need to add my custom created widget to my custom created above mentioned page in the footer container place, can some one assist me?

My custom widget placed in

app/code/Toptal/CustomWidget

This is how my frontend/layout code looks like now where I'm trying to include custom widget: (i think missing name="" value, but I dont know correct what should be)

    <?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="content">
        <block
                template="content.phtml"
                class="Pulsestorm\HelloWorldMVVM\Block\Main"
                name="pulsestorm_helloworld_mvvm"/>
    </referenceBlock>
    <referenceContainer name="footer-container"> 
        <block template="samplewidget.phtml" 
               class="Toptal\CustomWidget\Block\Widget\Samplewidget" 
               name=""/> 
    </referenceContainer>
</page>
  • What class and template use your widget? – Evgeny Levinsky Jun 19 '18 at 18:15
  • template name: samplewidget.phtml , class if I'm right is: Toptal\CustomWidget\Block\Widget\Samplewidget ? – Kristijanas Kiseliovas Jun 20 '18 at 7:33
  • My code looks now: <referenceContainer name="footer-container"> <block template="samplewidget.phtml" class="Toptal\CustomWidget\Block\Widget\Samplewidget" name=""/> </referenceContainer> – Kristijanas Kiseliovas Jun 20 '18 at 7:37
1

First you have add your block name then you need to move your block like below code:

<referenceContainer name="footer-container"> 
    <block template="samplewidget.phtml" 
           class="Toptal\CustomWidget\Block\Widget\Samplewidget" 
           name="widget.name"/> 
</referenceContainer>

<move element="widget.name" destination="footer-container" before="-"/>

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.