2

I managed to develop a custom widget, the problem is that its not displaying in the frontend.

The goal is to add the widget to a static block and then display the block in frontend.

I created the static block and added the widget, for test purposes was added some static text after the widget so to make sure the block is displaying and it does (the static text displays, but the widget content doesn't);

In the Block class in my widget i have the following code.

    class MP_Novidades_Block_Produtos
    extends Mage_Core_Block_Template
    implements Mage_Widget_Block_Interface
{

    public function _toHtml () {
        $_data = $this->getData();
        return "<a href='#'>Test</a>";
    }

}

In the layout file - page.xml i added this block.

 <block type="cms/block" name="banners_block" before="-">
            <action method="setBlockId">
                <block_id>banners_block</block_id>
            </action>
        </block>

widget.xml

 <?xml version="1.0"?>
 <widgets>
<novidades_nov type="novidades/produtos">
    <name>Produtos Novidade</name>
    <description type="desc">Cria lista de produtos novidade</description>
    <parameters>
        <hyperlink>
            <required>1</required>
            <visible>1</visible>
            <value>http://www.maispormenos.eu</value>
            <label>URL de ligação</label>
            <type>text</type>
        </hyperlink>
        <button_text>
            <required>1</required>
            <visible>1</visible>
            <value>Ir</value>
            <label>Texto do botão</label>
            <type>text</type>
        </button_text>
        <image>
            <required>1</required>
            <visible>1</visible>
            <value>-</value>
            <label>Imagem</label>
            <type>text</type>
        </image>
    </parameters>
  </novidades_nov>
</widgets>

it's supposed to show that tag, but it doesnt. What can be the causes for this to happen?

Thanks in advance and happy Magento programming!

  • please show widget.xml code here – Anil Suthar Jul 25 '16 at 11:22
  • @AnilSuthar i edited the question and added the widget.xml structure. – Miguel Pinto Jul 25 '16 at 11:43
0

Best tutorial I have ever found to create custom widgets is http://code.tutsplus.com/tutorials/custom-widget-development-in-magento--cms-23015

Please match your process with this tutorial. I hope it will surely help you.

0

Have you tried to add output parameter?

<block type="cms/block" name="banners_block" before="-" output="toHtml">
    <action method="setBlockId">
        <block_id>banners_block</block_id>
    </action>
</block>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.