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

时间:2015-08-13 05:53:57

标签: php magento frontend magento-1.8 magento-1.9

我正在使用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>

2 个答案:

答案 0 :(得分:1)

按如下所示更新布局

<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')

答案 1 :(得分:0)

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') ?>