3

I have created my package based on rwd magento 1.9. When I click on a category, say, Women I go to page

frontend/my_package/default/template/page/1column.phtml (template hints)

In the middle of this page there is a block with template hint:

frontend/base/default/template/catalog/category/view.phtml

and Mage_Catalog_Block_Category_View. I want to place my module which has subcategories with images into this block. I just can't find the name of the block to insert into. In my layout file I want something like:

  <catalog_category_view>
    <reference name="????????">
       <block type="women/subcategories"  name="subcategoriesblock" as="subcategoriesblock"      template="subcats/subcats.phtml"/>
    </reference>
  </catalog_category_view>

I have used

$blocks = Mage::app()->getLayout()->getAllBlocks();

to get block names in current page and have tried and tested the various block names but nothing seems to work. Could somebody help and give some suggestion as to how I might get the name of the relevant block. All help will be greatly appreciated.

  • Pls enable both "Template Path Hints" & "Add Block Names to Hints" in admin end and check again. I thing your got relevant block name. – Abdul Jul 21 '16 at 6:53
13

On top of what everyone else said, you can use the following code in the template file to find out the block name:

$this->getNameInLayout();
1

Its name is category.products.

I got it by doing grep -rn 'catalog/category/view.phtml' app/design/frontend/rwd/default

Even if not using grep, you can just look at app/design/frontend/rwd/default/layout/catalog.xml and see how the page is built up.

0

In Magento 1.x, blocks are classes whose functions can be called with $this directly in respective template files.

If you have created relevant block file(s) for calling your module's template file(s), then you know better that which block file functions could be used most in your template (.phtml) file.

If you have not created block class file for your module, then you can use core/template instead.

I hope I could explain my point.

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.