有时我们需要在主页上显示带有图像的网上商店类别,这很简单
只需创建一个页面调用它hopepage.phtml
然后转到magento后端并调用cms块。
我不知道怎么做“call cms block.
谢谢
答案 0 :(得分:0)
为什么不自动生成图片/类别列表?
页面的布局XML:
<reference name="content">
<block type="core/template" name="main.search" as="mainSearch" template="catalogsearch/form.mini.phtml"/>
<block type="catalog/navigation" name="home.catalog.category.list" as="home_catalog_category_list" template="catalog/category/list.phtml" after="cms_page" />
</reference>
您的主题应在./template/catalog/category/list.phtml
<?php $_categories = $this->getStoreCategories(); ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
<div class="category-list-main">
<ul>
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<li class="main-category">
<a href="<?php echo $this->getCategoryUrl($_category); ?>">
<?php
if ($category_image_url = Mage::getModel('catalog/category')->setData($_category->getData())->load($_category->getId())->getThumbnail()):
?>
<img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$category_image_url; ?>">
<?php
endif;
?>
<?php echo $this->htmlEscape($_category->getName()); ?>
</a>
</li>
<?php endif; ?>
<?php endforeach ?>
</ul>
</div>
<?php endif; ?>