我们正在视图页面中显示文本字段,以检查COD的可用性。
view.phtml
echo $this->getLayout()->createBlock('core/template')->setTemplate('checkdelivery/checkdelivery.phtml')->toHtml();
在view.phtml
我们下面的文件中调用。但是我想调用静态块标识符 [identifier code-check]而不是下面的文件。
模板/checkdelivery/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" value="<?php echo Mage::getModel('core/cookie')->get('zip'); ?>" 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 if(Mage::getModel('core/cookie')->get('message')){
echo Mage::getModel('core/cookie')->get('message');
}
else{
$defaultHtml; } ?></div>
<br>
</div>
</div>
<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);
}
});
});
</script>
静态块代码:
<p>{{block type ="core/template" template = "checkdelivery/checkdelivery.phtml"}}</p>