Trying to insert custom template/block into specific place in => product.info.addto
for some reason my block appears either before or after and I can't manage to insert it anywhere else.
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<catalog_product_view>
<reference name="content">
<block type="amber_custom/catalog_product_custom" name="linked.product" template="amber/catalog/product/custom.phtml" after="product.reviews"/> <!-- trying inset it after this block but no luck -->
</reference>
</catalog_product_view>
</layout>
What is the problem, why it won't go there ?
To find out all the block names i'm using "ath" – advanced theme hint , it shows all the names correctly.
Best Answer
Changes
catalog/product/view.phtml
into to your theme if it isn't already (never directly edit core files or you could lose your changes)<?php echo $this->getChildHtml('linked.product') ?>
to where you want it to render<reference name="content">
to<reference name="product.info">
Explanation
The problem arises because you're using
<reference name="content">
-content
is a structural block and structural blocks will automatically render child blocks and this is your problem as it can be difficult to position blocks this way.Why before/after isn't working for you
after
isn't working for you because your block is using the referencecontent
whilstproduct.reviews
inside the reference ofproduct.info
.You're best bet is to use
<reference name="product.info">
rather thancontent
and then copy overcatalog/product/view.phtml
into your theme if it isn't already (never edit the core or Ben Marks will hunt you down).Now inside this template add the following:
This will render your block where ever you add that line of code.
At first the above seems a bit strange and not so straight forward, but after you've done it a few times it becomes second nature and actually makes sense.