Add custom template to existing widget (product_list)
I would like to make use of a product list widget but I need to use it with my own template file.
I want to create a widget via content -> widgets. This is different from utilizing a widget from a CMS page or block.

But there is only the default "Products Grid Template".
So I found this post: Magento2: How to override widget template
But the solution explained does not work.
I am using magento 2.2.3. I created a custom module...
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="module.xsd">
<module name="Vendor_Module" setup_version="0.0.1">
<sequence>
<module name="Magento_CatalogWidget" />
</sequence>
</module>
...with a widget.xml in the module's etc/ folder:
<?xml version="1.0" encoding="UTF-8"?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget_file.xsd">
<widget id="products_list" class="MagentoCatalogWidgetBlockProductProductsList" is_email_compatible="true" placeholder_image="Magento_CatalogWidget::images/products_list.png" ttl="86400">
<parameters>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Bestseller</label>
<options>
<option name="bestseller" value="Vendor_Module::widget/bestseller.phtml">
<label translate="true">Bestseller</label>
</option>
</options>
</parameter>
</parameters>
</widget>
And put my template file in
app/code/Vendor/Module/view/frontend/widget/bestseller.phtml
Cleared all caches but the template won't show up as an option in the widget's admin interface.
Any idea what could be wrong here?
Thank you
EDIT:
This template thing does not make any sense. I tried to dig into this by looking at other modules.
I took the mageplaza blog extension for instance. It comes with a similar widget:
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="mageplaza_blog_posts" class="MageplazaBlogBlockWidgetPosts">
<label translate="true">Mageplaza Blog</label>
<description>Mageplaza Blog Widget </description>
<parameters>
<parameter name="title" xsi:type="text" required="false" visible="true">
<label translate="true">Title</label>
</parameter>
<parameter name="post_count" xsi:type="text" required="true" visible="true">
<label translate="true">Numbers of Posts Display</label>
<value>5</value>
</parameter>
<parameter name="show_type" xsi:type="select" required="false" visible="true"
source_model="MageplazaBlogModelConfigSourceWidgetShowType">
<label translate="true">Show Type</label>
</parameter>
<parameter name="category_id" xsi:type="text" required="true" visible="true">
<label translate="true">Category ID</label>
<depends>
<parameter name="show_type" value="category" />
</depends>
<value>2</value>
</parameter>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Template</label>
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
</options>
</parameter>
</parameters>
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
</widget>
Now when I expand the widget.xml inside the module:
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
This does not have ANY effect whatsoever. There is no way to select the second template. It sticks to "Default Posts Template".
magento2 template widget
add a comment |
I would like to make use of a product list widget but I need to use it with my own template file.
I want to create a widget via content -> widgets. This is different from utilizing a widget from a CMS page or block.

But there is only the default "Products Grid Template".
So I found this post: Magento2: How to override widget template
But the solution explained does not work.
I am using magento 2.2.3. I created a custom module...
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="module.xsd">
<module name="Vendor_Module" setup_version="0.0.1">
<sequence>
<module name="Magento_CatalogWidget" />
</sequence>
</module>
...with a widget.xml in the module's etc/ folder:
<?xml version="1.0" encoding="UTF-8"?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget_file.xsd">
<widget id="products_list" class="MagentoCatalogWidgetBlockProductProductsList" is_email_compatible="true" placeholder_image="Magento_CatalogWidget::images/products_list.png" ttl="86400">
<parameters>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Bestseller</label>
<options>
<option name="bestseller" value="Vendor_Module::widget/bestseller.phtml">
<label translate="true">Bestseller</label>
</option>
</options>
</parameter>
</parameters>
</widget>
And put my template file in
app/code/Vendor/Module/view/frontend/widget/bestseller.phtml
Cleared all caches but the template won't show up as an option in the widget's admin interface.
Any idea what could be wrong here?
Thank you
EDIT:
This template thing does not make any sense. I tried to dig into this by looking at other modules.
I took the mageplaza blog extension for instance. It comes with a similar widget:
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="mageplaza_blog_posts" class="MageplazaBlogBlockWidgetPosts">
<label translate="true">Mageplaza Blog</label>
<description>Mageplaza Blog Widget </description>
<parameters>
<parameter name="title" xsi:type="text" required="false" visible="true">
<label translate="true">Title</label>
</parameter>
<parameter name="post_count" xsi:type="text" required="true" visible="true">
<label translate="true">Numbers of Posts Display</label>
<value>5</value>
</parameter>
<parameter name="show_type" xsi:type="select" required="false" visible="true"
source_model="MageplazaBlogModelConfigSourceWidgetShowType">
<label translate="true">Show Type</label>
</parameter>
<parameter name="category_id" xsi:type="text" required="true" visible="true">
<label translate="true">Category ID</label>
<depends>
<parameter name="show_type" value="category" />
</depends>
<value>2</value>
</parameter>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Template</label>
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
</options>
</parameter>
</parameters>
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
</widget>
Now when I expand the widget.xml inside the module:
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
This does not have ANY effect whatsoever. There is no way to select the second template. It sticks to "Default Posts Template".
magento2 template widget
add a comment |
I would like to make use of a product list widget but I need to use it with my own template file.
I want to create a widget via content -> widgets. This is different from utilizing a widget from a CMS page or block.

But there is only the default "Products Grid Template".
So I found this post: Magento2: How to override widget template
But the solution explained does not work.
I am using magento 2.2.3. I created a custom module...
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="module.xsd">
<module name="Vendor_Module" setup_version="0.0.1">
<sequence>
<module name="Magento_CatalogWidget" />
</sequence>
</module>
...with a widget.xml in the module's etc/ folder:
<?xml version="1.0" encoding="UTF-8"?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget_file.xsd">
<widget id="products_list" class="MagentoCatalogWidgetBlockProductProductsList" is_email_compatible="true" placeholder_image="Magento_CatalogWidget::images/products_list.png" ttl="86400">
<parameters>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Bestseller</label>
<options>
<option name="bestseller" value="Vendor_Module::widget/bestseller.phtml">
<label translate="true">Bestseller</label>
</option>
</options>
</parameter>
</parameters>
</widget>
And put my template file in
app/code/Vendor/Module/view/frontend/widget/bestseller.phtml
Cleared all caches but the template won't show up as an option in the widget's admin interface.
Any idea what could be wrong here?
Thank you
EDIT:
This template thing does not make any sense. I tried to dig into this by looking at other modules.
I took the mageplaza blog extension for instance. It comes with a similar widget:
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="mageplaza_blog_posts" class="MageplazaBlogBlockWidgetPosts">
<label translate="true">Mageplaza Blog</label>
<description>Mageplaza Blog Widget </description>
<parameters>
<parameter name="title" xsi:type="text" required="false" visible="true">
<label translate="true">Title</label>
</parameter>
<parameter name="post_count" xsi:type="text" required="true" visible="true">
<label translate="true">Numbers of Posts Display</label>
<value>5</value>
</parameter>
<parameter name="show_type" xsi:type="select" required="false" visible="true"
source_model="MageplazaBlogModelConfigSourceWidgetShowType">
<label translate="true">Show Type</label>
</parameter>
<parameter name="category_id" xsi:type="text" required="true" visible="true">
<label translate="true">Category ID</label>
<depends>
<parameter name="show_type" value="category" />
</depends>
<value>2</value>
</parameter>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Template</label>
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
</options>
</parameter>
</parameters>
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
</widget>
Now when I expand the widget.xml inside the module:
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
This does not have ANY effect whatsoever. There is no way to select the second template. It sticks to "Default Posts Template".
magento2 template widget
I would like to make use of a product list widget but I need to use it with my own template file.
I want to create a widget via content -> widgets. This is different from utilizing a widget from a CMS page or block.

But there is only the default "Products Grid Template".
So I found this post: Magento2: How to override widget template
But the solution explained does not work.
I am using magento 2.2.3. I created a custom module...
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="module.xsd">
<module name="Vendor_Module" setup_version="0.0.1">
<sequence>
<module name="Magento_CatalogWidget" />
</sequence>
</module>
...with a widget.xml in the module's etc/ folder:
<?xml version="1.0" encoding="UTF-8"?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget_file.xsd">
<widget id="products_list" class="MagentoCatalogWidgetBlockProductProductsList" is_email_compatible="true" placeholder_image="Magento_CatalogWidget::images/products_list.png" ttl="86400">
<parameters>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Bestseller</label>
<options>
<option name="bestseller" value="Vendor_Module::widget/bestseller.phtml">
<label translate="true">Bestseller</label>
</option>
</options>
</parameter>
</parameters>
</widget>
And put my template file in
app/code/Vendor/Module/view/frontend/widget/bestseller.phtml
Cleared all caches but the template won't show up as an option in the widget's admin interface.
Any idea what could be wrong here?
Thank you
EDIT:
This template thing does not make any sense. I tried to dig into this by looking at other modules.
I took the mageplaza blog extension for instance. It comes with a similar widget:
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="mageplaza_blog_posts" class="MageplazaBlogBlockWidgetPosts">
<label translate="true">Mageplaza Blog</label>
<description>Mageplaza Blog Widget </description>
<parameters>
<parameter name="title" xsi:type="text" required="false" visible="true">
<label translate="true">Title</label>
</parameter>
<parameter name="post_count" xsi:type="text" required="true" visible="true">
<label translate="true">Numbers of Posts Display</label>
<value>5</value>
</parameter>
<parameter name="show_type" xsi:type="select" required="false" visible="true"
source_model="MageplazaBlogModelConfigSourceWidgetShowType">
<label translate="true">Show Type</label>
</parameter>
<parameter name="category_id" xsi:type="text" required="true" visible="true">
<label translate="true">Category ID</label>
<depends>
<parameter name="show_type" value="category" />
</depends>
<value>2</value>
</parameter>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Template</label>
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
</options>
</parameter>
</parameters>
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
</widget>
Now when I expand the widget.xml inside the module:
<options>
<option name="posts" value="Mageplaza_Blog::widget/posts.phtml" selected="true">
<label translate="true">Default Posts Template</label>
</option>
<option name="posts2" value="Mageplaza_Blog::widget/posts2.phtml">
<label translate="true">Default Posts Template2</label>
</option>
This does not have ANY effect whatsoever. There is no way to select the second template. It sticks to "Default Posts Template".
magento2 template widget
magento2 template widget
edited Apr 27 '18 at 14:57
omsta
asked Apr 27 '18 at 9:26
omstaomsta
1128
1128
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I think that the problem is your path of the template. The correct location will be this:
app/code/Vendor/Module/view/frontend/templates/widget/bestseller.phtml
You forgot the folder templates
add a comment |
Your issue might be here:
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
Should also contain:
<template name="posts2" value="posts2" />
The template name references the option name above.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f223968%2fadd-custom-template-to-existing-widget-product-list%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
I think that the problem is your path of the template. The correct location will be this:
app/code/Vendor/Module/view/frontend/templates/widget/bestseller.phtml
You forgot the folder templates
add a comment |
I think that the problem is your path of the template. The correct location will be this:
app/code/Vendor/Module/view/frontend/templates/widget/bestseller.phtml
You forgot the folder templates
add a comment |
I think that the problem is your path of the template. The correct location will be this:
app/code/Vendor/Module/view/frontend/templates/widget/bestseller.phtml
You forgot the folder templates
I think that the problem is your path of the template. The correct location will be this:
app/code/Vendor/Module/view/frontend/templates/widget/bestseller.phtml
You forgot the folder templates
answered Aug 7 '18 at 11:21
raumatbelraumatbel
669212
669212
add a comment |
add a comment |
Your issue might be here:
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
Should also contain:
<template name="posts2" value="posts2" />
The template name references the option name above.
add a comment |
Your issue might be here:
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
Should also contain:
<template name="posts2" value="posts2" />
The template name references the option name above.
add a comment |
Your issue might be here:
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
Should also contain:
<template name="posts2" value="posts2" />
The template name references the option name above.
Your issue might be here:
<containers>
<container name="content">
<template name="posts" value="posts" />
</container>
</containers>
Should also contain:
<template name="posts2" value="posts2" />
The template name references the option name above.
answered Jan 14 at 18:18
DWilsDWils
55121028
55121028
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f223968%2fadd-custom-template-to-existing-widget-product-list%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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