1

I have created a block accrording to this tutorial: http://www.gravitywell.co.uk/blog/post/how-to-creating-your-own-custom-block-in-magento . Now I need to use my manufacturerblock.phtml on my pruduct view page (just somewhere closed to product description text).

In local.xml (under <reference name="header">) I added: (edit: I tried also under <reference name="product.info"> in <catalog_product_view>

<block type="aimitmanufacturerblock/manufacturerblock" name="manufacturerblock" as="manufacturerblock" template="aimitmanufacturerblock/manufacturerblock.phtml" />

and I used <?php echo $this->getChildHtml('manufacturerblock')?> in my view.phtml.

But it seems the phtml is not included.

Swip
  • 173
  • 1
  • 7
  • 17

2 Answers2

2

If you want to use the block in catalog/product/view.phtml, you need to reference product.info in the catalog_product_view handle. And I can just assume that the module is activated, the class alias is declared, the class is created and the cache is flushed

OSdave
  • 8,538
  • 7
  • 45
  • 60
  • So do I understand correctly that I need to move this: just below in my local.xml? I did that now, but still doesn't show the echo from manufacturerblock.phtml. And your assumption is correct - I have activated module, class is declared correctly and cache is turned off. – Swip Feb 03 '13 at 12:24
2

Edit: Apologies, I should have followed the link to the tutorial you gave first, I see it's all about creating a new block type! However, I'll leave my answer for the moment - why do you need to create a new block type at all, there are loads of built in block types?. This answer from Clockworkgeek could be useful to you too;

Create a new Block in Magento

Original answer;

The issue is your block type - the block type isn't like a variable that you define yourself, there are specific built-in Magento block types which are used to instantiate the appropriate classes. This SO thread will be useful to you for further explanation;

Understanding Magento Block and Block Type

For another great explanation on block types read this one too;

What Block Type for Left Column in Magento Theme?

Community
  • 1
  • 1
McNab
  • 6,767
  • 4
  • 35
  • 55
  • Well I am trying to create an own module that will show a specific information about manufacturer including it's other products etc. So I assume that I need to have my own module with own block. – Swip Feb 03 '13 at 12:26
  • I know if I am creating a block using a specific custom template, and that block is displaying a list of products I would use `catalog/product_list` as the block type. – McNab Feb 03 '13 at 13:01
  • When I tried this, I get an error while loading the page. I use getChildHtml('manufacturerblock')?> for calling the block. Guess that's correct..? – Swip Feb 03 '13 at 13:12
  • Just thinking - is my local.xml record correct? I have the phtml file in folder \template\aimit\manufacturerblock\manufacturerblock.phtml – Swip Feb 03 '13 at 13:18
  • Got it working now!! My I had one more folder, which caused that it was not loaded! But thank you very much! Your post helped a lot! – Swip Feb 03 '13 at 13:24