首页 > 代码库 > 修改首页导航菜单的位置
修改首页导航菜单的位置
将首页的导航菜单移入到 banner下面的方法:
进入后台,在cms-page-设计:
右边:
1.<reference name="content">
2.<block type="catalog/product_new" name="home.catalog.product.new" template="catalog/product/tabMenu.phtml" after="cms_page">
3.<action method="setProductsCount"><count>4</count></action>
4.<action method="addPriceBlockType">
5.<type>bundle</type>
6.<block>bundle/catalog_product_price</block>
7.<template>bundle/catalog/product/price.phtml</template>
8.</action>
9.<action method="setColumnCount"><count>4</count></action>
10.</block>
11.</reference>
在第2行之前插入:
<block type="catalog/navigation" name="cms_catalog" template="catalog/catalog.phtml"/>
然后在 app\design\frontend\rwd\default\template\catalog 下新建 catalog.phtml 文件,其内容为以下代码:
<?php $current_cat = $this->getCurrentCategory();?>
<?php $current_cat = (is_object($current_cat) ? $current_cat->getName() : ‘‘);?><div class="catalog">
<?php $collection = $this->getStoreCategories();?>
<?php foreach ($collection as $_category):?>
<?php if ($_category->getName() == $current_cat) {?>
<a href="http://www.mamicode.com/<?php echo "><?php echo $_category->getName()?><br/>
<?php }else{ ?>
<h2><a href="http://www.mamicode.com/<?php echo "> <?php echo $_category->getName()?></a></h2>
<?php }?>
<?php foreach($_category->getChildren() as $_childCategory):?>
<?php if ($_childCategory->getName() == $current_cat) {?>
<a href="http://www.mamicode.com/<?php echo "><?php echo $_childCategory->getName()?></a><br/>
<?php }else{ ?>
<h6><a href="http://www.mamicode.com/<?php echo $this->getCategoryUrl($_childCategory)?>"><?php echo $_childCategory->getName()?></a></h6>
<?php }?>
<?php foreach($_childCategory->getChildren() as $_cchildCategory):?>
<?php if ($_cchildCategory->getName() == $current_cat) {?>
<a href="http://www.mamicode.com/<?php echo "><?php echo $_cchildCategory->getName()?></a><br/>
<?php }else{ ?>
<h6 style="margin-left:10px;"><a href="http://www.mamicode.com/<?php echo "><?php echo $_cchildCategory->getName()?></a></h6>
<?php }?>
<?php endforeach?>
<?php endforeach?>
<?php endforeach?>
</div>
这样前台就可以看到效果了。。