Saturday 15 March 2014

Magento Custom Block loads anonymously but not when declared in layout file -


I can not understand it ... it shows the correct html:

  file : /design/default/template/catalog/product/view.phtml & lt ;? Php ek $ this- & gt; GetLayout () - & gt; Make Block ('Core / Template') - & gt; Settemplate ('catalog / product /view/teasers.phtml') - & gt; ToHtml (); ? & Gt;   

But if I local. I declare blocks in xml and use getChildHtml (), then it does not work:

  file: / design / default / layout / local.xml < Catalog_product_view translation = "label" & gt; & Lt; Reference Name = "Content" & gt; & Lt; Block template = "catalog / product / view / teasers.file" type = "core / template" name = "teaser" = "teaser" & gt; & Lt; / Block & gt; & Lt; / References & gt; & Lt; / Catalog_product_view & gt;   

  File: /design/default/template/catalog/product/view.phtml << Php echo $ this- & gt; GetChildHtml ('teaser'); ? & Gt;   

Do I need anything more ??

This question does not matter to an experienced Magento developer. Hopefully it does not understand why it does help to solve your problem.

First of all, your path to local.xml is incorrect.

  / design / default / layout / local / .xml   

Here is the structure of Magento

  app / design / frontend / package-name / theme-name /layout/local.xml   

You are missing the package and / or theme name from your path, it is difficult to give advice to you. Are you sure that Magento sees your local.xml file? (This is a quick way of making invalid XML and how to reload in an error search)

Secondly, you have said that you getChildHtml ??? ? But along with that you are adding it to the content block content block is a test / list block which will automatically add any block. There is no phtml template in the content block, so you can not call getChildHtml . Where are you calling from getChildHtml ?

No comments:

Post a Comment