Question

Following on from my previous post, I created a simple 'hello world' style widget which parses a google-docs hosted excel csv and prints a table from the data - this part works wonderfully, but when I insert it into a CMS page, it displays right at the top directly beneath the 'breadcrumbs' block, you can see an example here, where the two sets of test text are meant to come before and after the table.

Please let me know which code would be useful to post, I don't want to post it all and create a wall of text!

Here is my block php file which just calls (I think) a template file which does all the parsing.

<?php
class Urbanrider_Scooterlistwidget_Block_Table
extends Mage_Core_Block_Abstract
implements Mage_Widget_Block_Interface
{
    protected function _Construct() {       

    $this->setTemplate('urbanrider/scooterlistwidget/table.phtml');

}

} ?>

Is this the right way to go about this? It's effectively a 'Hello World' widget.

Edit:

I have also tried using 'protected function toHtml()' and put all of the phtml template in there but I'm getting the same issue

Était-ce utile?

La solution

You do something like this in the cms:

(test before)
{{block type="urbanrider/scooterlistwidget" block_id="myblock" template="urbanrider/scooterlistwidget/table.phtml"}}
(test after)

Autres conseils

You can also set the template from block class like this:

<?php
class Urbanrider_Scooterlistwidget_Block_Table
extends Mage_Core_Block_Abstract
implements Mage_Widget_Block_Template
{
    protected function _toHtml() {       

    $this->setTemplate('urbanrider/scooterlistwidget/table.phtml');
    return parent::_toHtml();

}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top