2014-04-22 82 views
0

我试图将我的加密从产品的“内容”视图移到模板中的自己的部分。与Magento块和布局混淆

我的XML看起来是这样的:

<catalog_product_view translate="label"> 
    <reference name="root"> 
     <action method="setTemplate"> 
      <template>page/2columns-left.phtml</template> 
     </action> 
    </reference> 
    <reference name="content"> 
     <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml"> 
      ...other blocks... 
      <block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml" /> 
      ....other blocks... 
     </block> 
    </reference> 
</catalog_product_view> 

然后,内page/2columns-left.phtml它调用$this->getChildHtml('content')这使得catalog/product/view.phtml,然后该文件中的调用来$this->getChildHtml('upsell_products')制成。

我想要做的就是将'upsell_products'移出主'内容'视图(因为它被包装在模板的右栏中),并将其移动到主要的2列模板中,这样加售实际上可以坐在2列布局的下方并跨越页面的整个宽度,而不是被限制在右列。我知道我应该创建一个新的模板,因为现在这不仅仅是2列,但是设置它的正确方法是什么?我尝试了一堆不同的东西,似乎没有任何工作。我希望我已经包含了所有相关的信息。

回答

1

这就是我所做的。

添加下面的你local.xml中:

<catalog_product_view> 
    <reference name="root"> 
        <block type="core/text_list" name="bottom" as="bottom" translate="label"> 
            <label>bottom</label> 
        </block> 
    </reference> 
    <reference name="bottom"> 
     <block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml"> 
      <action method="setColumnCount"><columns>4</columns></action> 
      <action method="setItemLimit"><type>upsell</type><limit>4</limit></action> 
     </block> 
    </reference> 
</catalog_product_view> 

我创建了一个名为2columns-左下方新的模板,但你可以修改2columns左,如果你想。无论你选择的模板,你可以调用底部是这样的:

<div><?php echo $this->getChildHtml('bottom') ?></div> 

主容器COL2左布局地点此页脚上方和下方(外)。你会有一些div的样式,但我会把它留给你。

因此,这已经定义了一个新的结构块,就像'右'或'左',然后将upsell_products的内容放入其中。

hth,sconnie

+0

谢谢,没有意识到你必须声明块的根,我认为这就是让我绊倒。 – Drew