我有一个类别 ID,不想显示所有子类别。显示我应该在 Joomla 中这样做吗?
我试过以下
$catID = JRequest::getVar('id');
$categories = JCategories::getInstance('Content');
$cat = $categories->get($catID);
$children = JCategoryNode::getChildren($cat);
printObject($children);
但它不起作用。
最佳答案
getChildren
不是静态函数,您可以从从 get
获得的类别对象中调用它,它应该是 JCategoryNode 类型。
$catID = JRequest::getVar('id');
$categories = JCategories::getInstance('Content');
$cat = $categories->get($catID);
$children = $cat->getChildren();
print_r($children);
JCategorNode api
关于Joomla 获取自定义父类别的子类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17988998/