将块从右侧栏转移到主要内容

Transfer the block from right-sidebar to main content

我使用的是 magento 1.8.1,我安装了一个扩展程序,即 checkdelivery。但在前端,他们的块显示在右侧边栏中,但我不希望该页面上有右侧边栏。那么我如何将该块从右侧边栏转移到主要内容。

他们的 Phtml 文件:

    <div class="block block-list block-check-delivery">
<div class="block-title">
    <?php $blockLabel = Mage::getStoreConfig('checkdelivery/general/block_title'); ?>
    <strong><span><?php echo $this->__($blockLabel) ?></span></strong>
</div>
<div class="block-content" >        
    <br>
        <input name="zipcode" size="17" type="text" id="zipcode" maxlength="10" class="input-text" placeholder="<?php echo $this->__('Enter ZIP Code'); ?>"/>
        <button type="button" name="zip-check" title="Check" class="button" id="zip-check" ><span><?php echo $this->__('Check'); ?></span></button>
        <div id="delivery-message"></div>
        <?php $defaultHtml = Mage::getStoreConfig('checkdelivery/general/default_html'); ?>
        <div id="delivery-html"><?php echo $defaultHtml ?></div>

    <br>        
</div>

和Ajax代码:

  <script>
Event.observe('zip-check', 'click', function(event){
    new Ajax.Request("<?php echo $this->getUrl('checkdelivery/index/index') ?>", {
        method: "get",
        parameters: {zipcode : $('zipcode').value },
        onSuccess: function(transport) {
             var json = transport.responseText.evalJSON();
             $('delivery-message').update(json.message);                 
             $('delivery-message').setStyle({ color: json.color});
             $('delivery-html').update(json.html);  
        }
    });
});

layout.xml

   <layout version="0.1.0">

<catalog_product_view>
    <reference name="right" > 
        <block type="checkdelivery/checkdelivery" before="-" name="checkdelivery"> 
            <action method="setTemplate" ifconfig="checkdelivery/general/active">
                <template>checkdelivery/checkdelivery.phtml</template>
            </action>
        </block>
    </reference> 
</catalog_product_view>
<catalog_product_view>
    <block type="checkdelivery/checkdelivery" before="-" name="checkdelivery"> 
        <action method="setTemplate" ifconfig="checkdelivery/general/active">
            <template>checkdelivery/checkdelivery.phtml</template>
        </action> 
    </block>
</catalog_product_view>

更新您的布局如下

<catalog_product_view>
  <reference name="content">
    <block type="checkdelivery/checkdelivery" name="checkdelivery" as="checkdelivery"> 
        <action method="setTemplate" ifconfig="checkdelivery/general/active">
            <template>checkdelivery/checkdelivery.phtml</template>
        </action> 
    </block>
  </reference>  
</catalog_product_view>

并调用 product/view.phtml 中的块,如下所示:

echo $this->getChildHtml('checkdelivery')

在您的 local.xml 文件中使用它。

<layout>
    <catalog_product_view>
        <remove name="checkdelivery" />
        <reference name="content">
            <block type="checkdelivery/checkdelivery" name="checkdelivery">
                <action method="setTemplate" ifconfig="checkdelivery/general/active">
                    <template>checkdelivery/checkdelivery.phtml</template>
                </action>
            </block>
        </reference>
    </catalog_product_view>
</layout>

然后像这样在 view.phtml 中调用你的块。

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