Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.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
Magento-将phtml文件添加到布局块_Magento - Fatal编程技术网

Magento-将phtml文件添加到布局块

Magento-将phtml文件添加到布局块,magento,Magento,我正在尝试添加一些代码,这些代码将在产品页面上直接显示低于产品价格的文本-此外,我正在尝试通过“Magento”的方式来实现这一点,方法不仅仅是将代码复制到view.phtml,而是创建at块,然后在布局文件中引用该块 不管是好是坏,我都在努力跟随 到目前为止,我已经创建了phtml文件,其中包含我想要显示的内容(sharethis.phtml) 在页面xml中创建了引用: <block type="core/text_list" name="sharethis" as="sharethi

我正在尝试添加一些代码,这些代码将在产品页面上直接显示低于产品价格的文本-此外,我正在尝试通过“Magento”的方式来实现这一点,方法不仅仅是将代码复制到view.phtml,而是创建at块,然后在布局文件中引用该块

不管是好是坏,我都在努力跟随

到目前为止,我已经创建了phtml文件,其中包含我想要显示的内容(sharethis.phtml) 在页面xml中创建了引用:

<block type="core/text_list" name="sharethis" as="sharethis"/>

就在这个街区之后

<block type="core/text_list" name="left" as="left" translate="label">
<label>Left Column</label>
</block>

左列
在catalog.xml中引用了该引用,就在第一个默认标记之后:

    <reference name="sharethis">
        <block type="catalog/product_new" name="sharethis" template="catalog/product/view/sharethis.phtml"/>
    </reference>

最后从view.phtml文件中调用该块,如下所示

<?php echo $this->getChildHtml('sharethis') ?>


但它没有出现。有什么建议吗?

我不认为你可以有两个同名的块(这里是你将得到的,因为你将两个块声明为“sharethis”)

我不认为你可以有两个同名的块(这里是你将得到的,因为你将两个块声明为“sharethis”)

你想添加一个结构块吗?还是只比价格低一块?因为他们是不同的。如果我了解您试图在catalog.xml(布局文件)中执行的操作,请添加:


...
...
...
...
基本上,要回显子块,所述块必须是您所在块的子块


此外,您的类型可能错误,请确保使用的类型正确。

是否要添加结构块?还是只比价格低一块?因为他们是不同的。如果我了解您试图在catalog.xml(布局文件)中执行的操作,请添加:


...
...
...
...
基本上,要回显子块,所述块必须是您所在块的子块


此外,您的类型可能错误,请确保您使用的是正确的类型。

您放置区块的位置取决于您试图让区块显示的确切位置。。。因此,如果这不起作用,我需要知道你到底想把“sharethis”块放在什么地方,这取决于你到底想把块放在什么地方。。。因此,如果这不起作用,我需要知道你到底想把“sharethis”块放在哪个块中
<catalog_product_view>
   ...
   <reference name="content">
       <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
        <!--- ADD THIS -->
           <block type="catalog/product_new" name="sharethis" template="catalog/product/view/sharethis.phtml"/>
        <!-- END ADD -->
       ...
       </block>
    ...
    </reference>
    ...
</catalog_product_view>