2010-11-07 37 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的可能微笑在你的代碼:)