cancel
Showing results for 
Search instead for 
Did you mean: 

How to override plugin template via XML?

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

How to override plugin template via XML?

Hey,

 

I downloaded MageFan Awesome Blog plugin for Magento 2.2 and I want to override a template file.

I've added my own plugin to try and do this:

app/code/Company/BlogOverride

I have this file tree:

 

|-etc
|-----module.xml
|-registration.php
|-view
|-----frontend
|---------layout
|-------------catalog_product_view.xml
|---------templates
|-------------catalog
|-----------------product
|---------------------relatedposts.phtml

the contents of my catalog_product_view.xml file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance dc" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="content.aside">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Company_BlogOverride::catalog/product/relatedposts.phtml</argument>
        </action>
    </referenceBlock>
</page>

I then run:

$ php bin/magento setup:upgrade
$ php bin/magento setup:di:compile
$ php bin/magento setup:static-content:deploy -f
$ php bin/magento cache:flush

but it still uses the default plugin template. How do I override it? I've raised an issue on Magento SE too: https://magento.stackexchange.com/questions/250857/how-do-i-override-plugin-phtml-file-added-by-xml

 

Thanks

1 REPLY 1

Re: How to override plugin template via XML?

Please show your 

catalog_product_view.xml

Xml code of module to check in more details.

 

Or You can override templates file at theme level without create module.

app/design/frontend/{Packagename}/{themename}/Magefan_Blog/templates/catalog/product/relatedpost.phtml

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial