0

I have a custom block (tabbed product info) which I want to display in the store's product view within the product view block itself. I correctly called the block in my view.phtml and use this code to add the block to my XML:

<block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs" template="catalog/product/view/tabs.phtml" >

The block is rendered when put into catalog.xml, but whenever I put it into my local.xml in form of

<catalog_product_view translate="label">
 <label>Catalog Product View (Any)</label>
   <reference name="content">
    <block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs" template="catalog/product/view/tabs.phtml" >
   </reference>
</catalog_product_view>

it does not work. When I add the before or after tag (e.g. after="product.info.media") to the code snippet in local.xml, it is rendered but not within, but always before or after the whole product view block. In catalog.xml, I just placed it at between the other blocks and it worked fine.

When I copy the content of the whole product view section from catalog.xml into my local.xml it works, but the all the content (images, description, etc.) is displayed twice.

Is there any way to do this via local.xml? Maybe through setchild?

2 Answers 2

1

When you talk about local.xml, are you talking about /app/etc/local.xml ? This file is a configuration file, not a layout update file. It's not intended to work like that.

If you are talking about another layout file (in app/design/<package>/<theme>/layout/local.xml) then you must add a dependency of the module which declared this layout update file to the module that declares original content of the page (in your case Mage_Catalog).

This is like that because, Magento after or before attributes compares only to already declared blocks, and I think your local.xml is parsed before the original catalog.xml

Let's assume that you have a module called StackOverflow_Local, that have in its config.xml (app/code/local/StackOverflow/Local/etc/config.xml) this declaration :

<config>
  <frontend>
    <layout>
      <updates>
        <stackoverflow_local>
          <file>local.xml</file>
        </stackoverflow_local>
      </updates>
    </layout>
  </frontend>
</config>  

Then you should have a declaration of your module in app/etc/modules/StackOverflow_Local.xml where you should find something like this :

<?xml version="1.0"?>
<config>
  <modules>
    <StackOverflow_Local>
      <active>true</active>
      <codePool>local</codePool>
    </StackOverflow_Local>
  </modules>
</config>

To add a dependancy (your module shouldn't work if Mage_Catalog is disabled/removed) transform your activation XML to this :

<?xml version="1.0"?>
<config>
  <modules>
    <StackOverflow_Local>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Mage_Catalog />
      </depends>
    </StackOverflow_Local>
  </modules>
</config>
Sign up to request clarification or add additional context in comments.

1 Comment

The assumption is that OP is talking about the local.xml layout file.
0

You are adding the block to the content block. Update your reference name value to product.info. Based on your alias of info_tabs, as long as your template has

echo $this->getChildHtml('info_tabs')

you should be good to go.

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.