cancel
Showing results for 
Search instead for 
Did you mean: 

Widget not rendering

Widget not rendering

I am currently working on a branding widget that I want to appear in the header block.  This widget takes a few settings determined by the site owner and then is supposed to insert the branding at the top of all pages.

 

Here is my widget XML:

 

<?xml version="1.0" ?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget class="Msu\TopBranding\Block\Widget\TopBrandWidget" id="Msu_TopBranding_TopBrandWidget">
<label>Top MSU Branding</label>
<description></description>
<parameters>
<parameter name="msu_brand_logo_color" sort_order="10" visible="true" required="true" xsi:type="select">
<label>MSU Logo Color</label>
<options>
<option name="green" value="#18453b">
<label>Green</label>
</option>
<option name="white" value="#ffffff">
<label>White</label>
</option>
<option name="black" value="#000000">
<label>Black</label>
</option>
</options>
</parameter>
<parameter name="msu_search_site_name" sort_order="20" visible="true" required="true" xsi:type="text">
<label>Site Name to Appear on Search Results</label>
</parameter>
<parameter name="msu_search_url" sort_order="20" visible="true" required="true" xsi:type="text">
<label>Your URL to search (must be a *.msu.edu domain)</label>
</parameter>
<parameter name="msu_brand_ga" sort_order="50" visible="true" required="false" xsi:type="text">
<label>Google Analytics ID</label>
</parameter>
<parameter name="template" sort_order="1000" visible="true" xsi:type="select">
<label>Template</label>
<options>
<option name="default" value="app/code/Msu/TopBranding/view/frontend/templates/widget/topbranding.phtml">
<label>Header Template</label>
</option>
</options>
</parameter>
</parameters>
<containers>
<container name="header.container">
<template name="top-branding" value="default" />
</container>
</containers>
</widget>
</widgets>

When I go to add my widget, I go to Content->Widgets->Add Widget and in the Layout Updates, I pick "Display on all pages", pick "Page Header Content", and then "Header Template" appears in the template column since it's the only option.  I then go to a page, and my widget doesn't appear.  I thought that maybe my path to my template was incorrect, and I can't find any documentation that explains how it works.

Any help is appreciated, I'm about at my wits end with this.

 

Thanks!

3 REPLIES

Re: Widget not rendering

Hi @eric_samson

 

Yes - there might be a reason you miss something !

 

Below i am sharing links for how to create a magento 2 custom widget and add it to header/pages as well.

 

https://www.cloudways.com/blog/magento-2-custom-widget/

 

http://www.dckap.com/blog/create-category-widget-magento-2/

 

https://www.cloudways.com/blog/magento-2-custom-widget/

 

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Widget not rendering

Hello @eric_samson

 

Please check log file under var/log folder.

 

 

Re: Widget not rendering

I looked at all of these earlier and used them as a base for what I am trying to do.  My template is /app/code/Msu/TopBranding/view/frontend/templates/widget/topbranding.phtml

 

This is how I reference it in widget.xml

 

<options>
<option name="default" value="app/code/Msu/TopBranding/view/frontend/templates/widget/topbranding.phtml">
<label>Header Template</label>
</option>
</options>