2010-11-07 35 views

回答

0

正式的方式来为自己做,这是使用该模块造物主(搜索Magento的连接此),然后创建一个模块:

创建一个包含以下代码的新PHTML文件:

$storeCategories = $this->getCats('my-category-url-key'); 
     foreach ($storeCategories as $category): 
      echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>'; 
     endforeach; 

然后一个叫(说)块Namespace_Yourmodule_Block_Singlecat用下面的代码:

public function getCats($catName) 
{ 
    $parent = Mage::getResourceModel('catalog/category_collection') 
        ->addAttributeToSelect('entity_id') 
        ->addAttributeToFilter('url_key', $catName) 
        ->getFirstItem(); 
    return $storeCategories = Mage::getModel('catalog/category') 
     ->getCategories($parent->getId(), $recursionLevel=1, $sorted=false, $asCollection=true, $toLoad=false); 
} 

然后你只需要插入以下节点到app\design\frontend\yourtheme\layout\yourmodule.xml布局文件:

<reference name="left"> 
     <block type="yourmodule/singlecat" name="singlecat" template="path/yourfilename.phtml" /> 
    </reference> 

交叉手指,祈祷你所选择的神性和Magento的可能微笑在你的代码:)