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就可以了