Joomla 获取自定义父类别的子类别

标签 joomla joomla2.5 joomla3.1

我有一个类别 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/

相关文章:

Joomla 插件安装文件

php随机丢失部分 session

joomla - 无法在 joomla 3.1.5 的前端禁用按钮?

php - 带有预装扩展的 Joomla

joomla - 为什么是 Joomla! K2不支持中文搜索?

css - 编辑用户注册表 xml

tags - Joomla 3.1.5 将标签保存到ucm_content和contentitem_tag_map

php - Joomla com_user 扩展类似于 com_categories 和 com_content

css - 在 Joomla 3.0 中修改 Protostar 模板菜单类

mysql - 本地开发joomla与远程数据库