1

I have a small custom module which is supposed to show on all product pages, but it doesn't. It only shows when setting its reference to "content", but I want it to display witin the already existing product view divs, thus, display it within the "product.info" reference.

Here's my code:

app/design/frontend/default/company/layout/company/socialbuttons.xml

<?xml version="1.0"?>
<layout>
  <catalog_product_view>
    <reference name="product.info">
     <block type="core/template" name="company_socialbuttons" template="company/socialbuttons.phtml" />
</reference>
  </catalog_product_view>
</layout>

I've spent hours finding the error, without success and if I can't find a solution soon I will do it the ugly way (calling the phtml inside the parent phtml). What am I doing wrong?

2 Answers 2

1

product.info handle is an instance of catalog/product_view block, and content is an instance of core/text_list block. The latter block is rendering every child block, even if there is no call to getChildHtml() method in the template.
So, if you want to add your block to product.info, you should call getChildHtml() method in the template.
Or, you can try reference of another blocks in product.info block: alert.urls or product.info.extrahint

Sign up to request clarification or add additional context in comments.

5 Comments

Great, the module is now displaying when referencing alert.urls (or product.info.extrahint). Just one more question: Is there a way to change the position of the alert.urls block via local.xml, without moving the getChildHtml('alert_urls') call in view.phtml?
@Socrates - Why would you want to use the alert.urls block for something completely different (social media buttons) just to avoid using a getChildHtml call. Wouldn't you rather the code was well written and structured?
@Socrates unfortunately, it's impossible to move alert_urls block using local.xml
@Drew I used product.alerts because I found no other way of making it show up inside the desired div. I tried it by calling my custom block core/template block but it never showed up inside the desired block.
@WebFlakeStudio Thanks for your help, I already noted your website and email, as I might have some more complicated work in the future :-)
1

If directly referencing the product.info block then you will have to use a call to getChildHtml() in your product view template:

echo $this->getChildHtml('company_socialbuttons');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.