4レベルのカテゴリがあります。
例 :
level0category --> level1category --> level2category -->lastlevel_level3cateogory
lastlevel で level2 のみのカテゴリを表示することは可能ですか? (カスタム left.phtml をロードするブロックで)
自動カテゴリ検出で何かを考えていたので、cat_id= を設定する必要はありません
編集:これは、さまざまなソースからのコードを組み合わせた後、私が探していたものです。
<?php
$currentCat = Mage::registry('current_category');
if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() )
{
// current category is a toplevel category
$loadCategory = $currentCat;
}
else
{
// current category is a sub-(or subsub-, etc...)category of a toplevel category
// load the parent category of the current category
$loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
// @TODO enhance for more nested category levels to display sub-categories
}
$subCategories = explode(',', $loadCategory->getChildren());
foreach ( $subCategories as $subCategoryId )
{
$cat = Mage::getModel('catalog/category')->load($subCategoryId);
if ($cat->getIsActive())
{
if ($currentCat->getEntityId() == $subCategoryId)
{
echo '<li style="display:none;">'.$cat->getName().'</li>';
}
else
{
echo '<a href="'.$cat->getURL().'">'.$cat->getName().'</a> <br>'; }
}
}
?>