版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/terry_water/article/details/82757040
block是按照顺序依次而来,依次画出来
如果想将某个部分的数据搞到顶部显示,而且这个数据是内容部分计算出来的,那么可以用下面的方式解决
1. 在 layout/template.phtml 文件的后面加上
<block type="core/text_list" name="page_header_top" >
你想要这个部分在哪里显示,就加到哪里,我是在顶部的菜单下面,因此我是在
messages的下面添加的
2.template/columns-left.phtml
breadcrumbs后面加入
<?php echo $helper->getModulesByPosition('page_header_top') ?>
3.在显示的顶部加入
$blockT = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'category_image_top',
array('template' => 'catalog/category/view/top_image.phtml')
);
$categoryImage = $current_category->getImage();
$width = 500;
$height = 200;
$imgUrl = $this->getCategoryImageUrl($categoryImage, $width, $height);
$blockT->assign('imageUrl', $imgUrl);
$this->getLayout()->getBlock('page_header_top')->append($blockT);
通过这种方式添加上block就可以了