Hello People, I have a an issue for any Magento Developers out there that I cannot resolve. I have created a custom module and block to be inculded in the category template. Here is a setup of my files
- app/code/local/Tsb.Category/etc/config.xml
<config>
> <modules>
> <Tsb_Category>
> <active>true</active>
> <codePool>local</codePool>
> </Tsb_Category>
> </modules>
> </config>
- app/etc/modules/Tsb_Category.xml
true local
app/code/local/Tsb/Category/Block/view.php
class Tsb_Category_Block_View extends Mage_Core_Block_Template
{ private $message; private $att;
protected function createMessage($msg) { $this->message = $msg; } public function receiveMessage() { if($this->message != '') { return $this->message; } else { $this->createMessage('Hello World'); return $this->message; } } protected function _toHtml() { $html = parent::_toHtml(); /*echo "MY CUSTOM ATTR IS" . $this->getData('my_custom'); echo "MY CUSTOM ATTR IS" . $this->getMyCustom(); */
}if($this->att = $this->getData('my_custom') && $this->getData('my_custom') != '') { $html .= '<br />'.$this->att; } else { $html .= '<br />No Custom Attribute Found'; } return $html;
}
/app/design/frontend/tsb/default/template/category/view.phtml
<div>
<span><strong>This is the output of the fido example:</strong></span><br />
<span style="color:#FF9933;">
<?php
echo $this->receiveMessage();
?>
/app/design/frontendtsb/default/layout/catalog.xml
<!--
Category default layout
-->
<catalog_category_default>
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
<reference name="content">
<!-- POSSIBLY CTAS FOR MAIN PRODUCT / TOP SELLER -->
<block type="tsb_category/view" my_custom="Test" template="category/view.phtml" before="category.products" />
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<!-- The following code shows how to set your own pager increments -->
<!--
<action method="setDefaultListPerPage"><limit>4</limit></action>
<action method="setDefaultGridPerPage"><limit>9</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
<action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
-->
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
</reference>
</catalog_category_default>
</span>
</div>
So there is the typical over the top Magento setup. Any ideas why when the Category pages are landed on the block displays correctly in the content and then again just before the closing tag.
Any help would be great.