Magento widget doesn't show custom template

magento, templates, widget

Solution

Too many possible things it could be, but here's some stuff to try.

What class does your `startslider/slider` widget inherit from? If it's not `Mage_Core_Block_Template` then you don't have a template widget block.

You created a `_toHtml` method for your widget — does this widget still call `parent::_toHtml();`. If not the template rendering code will never be run.

What does

var_dump($this->getData());
var_dump($this->getTemplate());
var_dump($this->getTemplateFile());

render from the `_toHtml` method? Do these paths match up exactly (including letter case) with the file system?

Problem

I set up a custom module with one custom widget in Magento. The widget should render some HTML in frontend. Therefore I created a custom .phtml file and configured it in widget.xml ``` <?xml version="1.0"?> <widgets> <startslider_slider type="startslider/slider "> <name>Slider Startpage</name> <description type="desc">Adds a slider</description> <parameters> <the_text> <label>myTestText</label> <visible>1</visible> <required>1</required> <type>text</type> </the_text> <template translate="label"> <label>Frontend Template</label> <visible>1</visible> <required>1</required> <type>select</type> <values> <three translate="label"> <value>startslider/slider-3.phtml</value> <label>Slider with three blocks</label> </three> <four translate="label"> <value>startslider/slider-4.phtml</value> <label>Slider with four blocks</label> </four> </values> </template> </parameters> </startslider_slider> </widgets> ``` I can insert and configure the widget in backend ( `{widget type="startslider/slider" the_text="blabla" template="startslider/slider-3.phtml"}` ) and in frontend the _toHtml() method of the block class is executed and some text is output, just for testing. But the content of the .phtml template is never shown. I'm wondering if Magento is unable to find the .phtml? I put the .phtml in the following locations: ``` magento-vhost/app/design/frontend/default/myCustomTheme/template/startslider/slider-3.phtml magento-vhost/app/design/frontend/default/default/template/startslider/slider-3.phtml magento-vhost/app/design/frontend/base/default/template/startslider/slider-3.phtml ``` Did I forget something? Do I have to configure sth. else to use custom .phtml?

Original source