Load custom block in category list page magento2












1














I am trying to add custom template file in category list page.



app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml



<referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Magento_Catalog::product/myCustomFile.phtml" />
</referenceContainer>


This is loading the template in list page.



But i need to load it from my custom module.



I used below code to implement it.



app/code/Vendor/Module/view/frontend/layout/module_index_index.xml



 <referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" />
</referenceContainer>


This is not loading my template in category list page. After using layout update also.



Can anyone help me on this please










share|improve this question






















  • Can you try to add it at app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml ?
    – amitshree
    Dec 31 '18 at 10:23










  • @amitshree, yes i need to add custom block in category page. yes tried it, that didn't work
    – jafar pinjar
    Dec 31 '18 at 10:36










  • This should work. Check here magento.stackexchange.com/a/181719/9169
    – amitshree
    Dec 31 '18 at 10:40










  • @amitshree, yes now it worked, thanks, the content of that phtml is like below, can we implement it there, magento.stackexchange.com/questions/256230/…
    – jafar pinjar
    Dec 31 '18 at 10:49










  • Yes you can do that with some customisation. You need to call current category and sub-categories and render them as per your need.
    – amitshree
    Dec 31 '18 at 10:53
















1














I am trying to add custom template file in category list page.



app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml



<referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Magento_Catalog::product/myCustomFile.phtml" />
</referenceContainer>


This is loading the template in list page.



But i need to load it from my custom module.



I used below code to implement it.



app/code/Vendor/Module/view/frontend/layout/module_index_index.xml



 <referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" />
</referenceContainer>


This is not loading my template in category list page. After using layout update also.



Can anyone help me on this please










share|improve this question






















  • Can you try to add it at app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml ?
    – amitshree
    Dec 31 '18 at 10:23










  • @amitshree, yes i need to add custom block in category page. yes tried it, that didn't work
    – jafar pinjar
    Dec 31 '18 at 10:36










  • This should work. Check here magento.stackexchange.com/a/181719/9169
    – amitshree
    Dec 31 '18 at 10:40










  • @amitshree, yes now it worked, thanks, the content of that phtml is like below, can we implement it there, magento.stackexchange.com/questions/256230/…
    – jafar pinjar
    Dec 31 '18 at 10:49










  • Yes you can do that with some customisation. You need to call current category and sub-categories and render them as per your need.
    – amitshree
    Dec 31 '18 at 10:53














1












1








1







I am trying to add custom template file in category list page.



app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml



<referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Magento_Catalog::product/myCustomFile.phtml" />
</referenceContainer>


This is loading the template in list page.



But i need to load it from my custom module.



I used below code to implement it.



app/code/Vendor/Module/view/frontend/layout/module_index_index.xml



 <referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" />
</referenceContainer>


This is not loading my template in category list page. After using layout update also.



Can anyone help me on this please










share|improve this question













I am trying to add custom template file in category list page.



app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml



<referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Magento_Catalog::product/myCustomFile.phtml" />
</referenceContainer>


This is loading the template in list page.



But i need to load it from my custom module.



I used below code to implement it.



app/code/Vendor/Module/view/frontend/layout/module_index_index.xml



 <referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" />
</referenceContainer>


This is not loading my template in category list page. After using layout update also.



Can anyone help me on this please







magento2 layout category-listing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 31 '18 at 10:06









jafar pinjar

618412




618412












  • Can you try to add it at app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml ?
    – amitshree
    Dec 31 '18 at 10:23










  • @amitshree, yes i need to add custom block in category page. yes tried it, that didn't work
    – jafar pinjar
    Dec 31 '18 at 10:36










  • This should work. Check here magento.stackexchange.com/a/181719/9169
    – amitshree
    Dec 31 '18 at 10:40










  • @amitshree, yes now it worked, thanks, the content of that phtml is like below, can we implement it there, magento.stackexchange.com/questions/256230/…
    – jafar pinjar
    Dec 31 '18 at 10:49










  • Yes you can do that with some customisation. You need to call current category and sub-categories and render them as per your need.
    – amitshree
    Dec 31 '18 at 10:53


















  • Can you try to add it at app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml ?
    – amitshree
    Dec 31 '18 at 10:23










  • @amitshree, yes i need to add custom block in category page. yes tried it, that didn't work
    – jafar pinjar
    Dec 31 '18 at 10:36










  • This should work. Check here magento.stackexchange.com/a/181719/9169
    – amitshree
    Dec 31 '18 at 10:40










  • @amitshree, yes now it worked, thanks, the content of that phtml is like below, can we implement it there, magento.stackexchange.com/questions/256230/…
    – jafar pinjar
    Dec 31 '18 at 10:49










  • Yes you can do that with some customisation. You need to call current category and sub-categories and render them as per your need.
    – amitshree
    Dec 31 '18 at 10:53
















Can you try to add it at app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml ?
– amitshree
Dec 31 '18 at 10:23




Can you try to add it at app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml ?
– amitshree
Dec 31 '18 at 10:23












@amitshree, yes i need to add custom block in category page. yes tried it, that didn't work
– jafar pinjar
Dec 31 '18 at 10:36




@amitshree, yes i need to add custom block in category page. yes tried it, that didn't work
– jafar pinjar
Dec 31 '18 at 10:36












This should work. Check here magento.stackexchange.com/a/181719/9169
– amitshree
Dec 31 '18 at 10:40




This should work. Check here magento.stackexchange.com/a/181719/9169
– amitshree
Dec 31 '18 at 10:40












@amitshree, yes now it worked, thanks, the content of that phtml is like below, can we implement it there, magento.stackexchange.com/questions/256230/…
– jafar pinjar
Dec 31 '18 at 10:49




@amitshree, yes now it worked, thanks, the content of that phtml is like below, can we implement it there, magento.stackexchange.com/questions/256230/…
– jafar pinjar
Dec 31 '18 at 10:49












Yes you can do that with some customisation. You need to call current category and sub-categories and render them as per your need.
– amitshree
Dec 31 '18 at 10:53




Yes you can do that with some customisation. You need to call current category and sub-categories and render them as per your need.
– amitshree
Dec 31 '18 at 10:53










2 Answers
2






active

oldest

votes


















2














create catalog_category_view.xml in your layout folder



app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml



<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Addify_ProductSold::css/sales_style.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" before="-" />

</referenceBlock>
</body>
</page>





share|improve this answer





















  • it worked thanks
    – jafar pinjar
    Dec 31 '18 at 12:13



















1














You need to add code like below.



<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_ModuleName::product/myCustomFile.phtml" />
</referenceContainer>
</body>
</page>


Thanks






share|improve this answer










New contributor




Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f256243%2fload-custom-block-in-category-list-page-magento2%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    create catalog_category_view.xml in your layout folder



    app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml



    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
    <css src="Addify_ProductSold::css/sales_style.css"/>
    </head>
    <body>
    <referenceContainer name="content">
    <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" before="-" />

    </referenceBlock>
    </body>
    </page>





    share|improve this answer





















    • it worked thanks
      – jafar pinjar
      Dec 31 '18 at 12:13
















    2














    create catalog_category_view.xml in your layout folder



    app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml



    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
    <css src="Addify_ProductSold::css/sales_style.css"/>
    </head>
    <body>
    <referenceContainer name="content">
    <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" before="-" />

    </referenceBlock>
    </body>
    </page>





    share|improve this answer





















    • it worked thanks
      – jafar pinjar
      Dec 31 '18 at 12:13














    2












    2








    2






    create catalog_category_view.xml in your layout folder



    app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml



    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
    <css src="Addify_ProductSold::css/sales_style.css"/>
    </head>
    <body>
    <referenceContainer name="content">
    <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" before="-" />

    </referenceBlock>
    </body>
    </page>





    share|improve this answer












    create catalog_category_view.xml in your layout folder



    app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml



    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
    <css src="Addify_ProductSold::css/sales_style.css"/>
    </head>
    <body>
    <referenceContainer name="content">
    <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_Module::product/myCustomFile.phtml" before="-" />

    </referenceBlock>
    </body>
    </page>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 31 '18 at 11:58









    Addify

    6845




    6845












    • it worked thanks
      – jafar pinjar
      Dec 31 '18 at 12:13


















    • it worked thanks
      – jafar pinjar
      Dec 31 '18 at 12:13
















    it worked thanks
    – jafar pinjar
    Dec 31 '18 at 12:13




    it worked thanks
    – jafar pinjar
    Dec 31 '18 at 12:13













    1














    You need to add code like below.



    <?xml version="1.0"?>
    <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <referenceContainer name="content">
    <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_ModuleName::product/myCustomFile.phtml" />
    </referenceContainer>
    </body>
    </page>


    Thanks






    share|improve this answer










    New contributor




    Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1














      You need to add code like below.



      <?xml version="1.0"?>
      <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <body>
      <referenceContainer name="content">
      <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_ModuleName::product/myCustomFile.phtml" />
      </referenceContainer>
      </body>
      </page>


      Thanks






      share|improve this answer










      New contributor




      Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















        1












        1








        1






        You need to add code like below.



        <?xml version="1.0"?>
        <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
        <referenceContainer name="content">
        <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_ModuleName::product/myCustomFile.phtml" />
        </referenceContainer>
        </body>
        </page>


        Thanks






        share|improve this answer










        New contributor




        Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        You need to add code like below.



        <?xml version="1.0"?>
        <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
        <referenceContainer name="content">
        <block class="MagentoFrameworkViewElementTemplate" name="custom.block" template="Vendor_ModuleName::product/myCustomFile.phtml" />
        </referenceContainer>
        </body>
        </page>


        Thanks







        share|improve this answer










        New contributor




        Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer








        edited Dec 31 '18 at 10:53









        Ashish Viradiya

        452219




        452219






        New contributor




        Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Dec 31 '18 at 10:47









        Sanket Kulkarni

        312




        312




        New contributor




        Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Sanket Kulkarni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f256243%2fload-custom-block-in-category-list-page-magento2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Сан-Квентин

            Алькесар

            Josef Freinademetz