Search code examples
magentoblockphp

Magento: include custom block in view.phtml


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.


Solution

  • 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?