Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento:自定义模块布局替代不起作用_Php_Xml_Magento_Layout - Fatal编程技术网

Php Magento:自定义模块布局替代不起作用

Php Magento:自定义模块布局替代不起作用,php,xml,magento,layout,Php,Xml,Magento,Layout,我有一个小的自定义模块,应该显示在所有产品页面上,但它没有。它仅在将其引用设置为“content”时显示,但我希望它在已经存在的产品视图div中显示,从而在“product.info”引用中显示它 这是我的密码: app/design/frontend/default/company/layout/company/socialbuttons.xml <?xml version="1.0"?> <layout> <catalog_product_view>

我有一个小的自定义模块,应该显示在所有产品页面上,但它没有。它仅在将其引用设置为“content”时显示,但我希望它在已经存在的产品视图div中显示,从而在“product.info”引用中显示它

这是我的密码:

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>


我已经花了数小时寻找错误,但没有成功,如果我不能很快找到解决方案,我将采用丑陋的方式(在父phtml中调用phtml)。我做错了什么?

如果直接引用product.info块,则必须在产品视图模板中调用getChildHtml()


echo$this->getChildHtml('company_socialbuttons')
product.info
句柄是
目录/产品视图
块的实例,
内容
核心/文本列表
块的实例。后一个块渲染每个子块,即使模板中没有调用
getChildHtml()
方法。
因此,如果要将块添加到
product.info
,应该在模板中调用
getChildHtml()
方法。

或者,您可以尝试引用
product.info
块中的其他块:
alert.url
product.info.extrahint

太好了,模块现在在引用alert.url(或product.info.extrahint)时显示。还有一个问题:有没有一种方法可以通过local.xml更改alert.url块的位置,而不移动view.phtml中的getChildHtml(“alert_url”)调用?@Socrates-你为什么要将alert.url块用于完全不同的东西(社交媒体按钮),只是为了避免使用getChildHtml调用。“难道你不希望代码写得好、结构好吗?”苏格拉底很不幸,无法使用本地移动警报URL块。xml@Drew我使用product.alerts是因为我没有找到其他方法使其显示在所需的分区中。我通过调用我的自定义块核心/模板块进行了尝试,但它从未显示在所需的块中。@WebFlakeStudio感谢您的帮助,我已经注意到您的网站和电子邮件,因为我将来可能会有一些更复杂的工作:-)