2012-11-08 36 views
0

我的插件项目的最终目标是让图像上传到数据库(完成),让它执行一些功能(完成),然后让它放置在某个任意位置在结帐/购物车由管理员(哦,恐怖)。在结帐/购物车中插入新块

我第一次只是试图将.phtml代码硬编码到此页面上的任何区块(为便于讨论,我们使用“checkout.cart.coupon”)。我的xml看起来像这样:

<checkout_cart_index> 
    <reference name="content"> 
     <block type="embeds/projecttemplates" name="project.offers.embed" template="project/button.phtml" after="checkout.cart.coupon"> 
     </block> 
    </reference> 
</checkout_cart_index> 

有了这个,我的块就出现在页面的末尾。之后改变只是将它转移到顶端。使用之前和之后的组合仍然保持在页面的顶部。有没有办法让它留在我告诉它的地方,而不必诉诸Prototype?

回答

1

如果您希望在优惠券区块内渲染名为“new”的区块,您必须执行两件事,因为优惠券区块使用模板。

步骤1:将通过

<reference name="checkout.cart.coupon" /> 

或 “新” 块父块的孩子在你的块声明中使用

parent="checkout.cart.coupon" 

属性。

第2步:自定义优惠券模板,以便它呈现与您的块:

<?php echo $this->getChildHtml('project.offers.embed') ?> 

如果你想获得的所有形而上的深刻和使用模板,你可以做到以下几点,这将是甜蜜的:

<checkout_cart_index> 
    <reference name="content"> 
     <block type="core/text_list" name="coupon.and.offers" as="coupon"> 
      <!-- 
       This block will displace the existing coupon block by alias, 
       but sill leave the coupon block instance in layout so it 
       can be added as a child. 
      --> 
      <action method="insert"> 
       <block>checkout.cart.coupon</block> 
      </action> 
      <block type="embeds/projecttemplates" name="project.offers.embed" template="project/button.phtml" after="checkout.cart.coupon" /> 
     </block> 
    </reference> 
</checkout_cart_index> 
+0

感谢您的答复。第一个肯定有效,但有被Magento更新删除的问题。如果我找不到其他解决方案,我可能不得不使用它。 至于第二个,我无法得到这个工作。它所做的只是创建第二个优惠券块,然后创建我的新块。玩弄它(并修复到)并没有太大的帮助。 – limasxgoesto0

+0

您需要执行我提到的两个步骤,并且您应该在* local.xml *布局文件中执行这些步骤 - 请告知我是否有帮助。 – benmarks

+0

啊,这是有道理的。对不起,我误解了!很可能会在周二尝试它。那么会让你知道。 – limasxgoesto0

相关问题