tags:

views:

726

answers:

1

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

  1. app/code/local/Tsb.Category/etc/config.xml

  <config>
>       <modules>
>        <Tsb_Category>
>         <active>true</active>
>         <codePool>local</codePool>
>        </Tsb_Category>
>       </modules>
>     </config>
  1. app/etc/modules/Tsb_Category.xml

true local

  1. 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-&gt;att = $this-&gt;getData('my_custom') &amp;&amp; $this-&gt;getData('my_custom') != '') 
    {
     $html .= '&lt;br /&gt;'.$this-&gt;att;
    } else {
     $html .= '&lt;br /&gt;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.

A: 

I am not a Developer also not sure my solution work for you.

you can try to change

<block type="tsb_category/view" my_custom="Test" template="category/view.phtml" before="category.products" />

to

<block type="tsb_category/view" my_custom="Test" name="category_view" as="category_view" template="category/view.phtml" before="category.products" />
Pankaj Pandey