php 获取Joomla模块中的com_content类别

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 获取Joomla模块中的com_content类别相关的知识,希望对你有一定的参考价值。

<?php
/**
* $list is a list of categories, usually in function getList() in module helper, see mod_articles_categories
*/

foreach ($list as $item) {
  // get parent category id
  $parent_category_id = $item->id;
  // get parent category params (if you need parent category image)
  $parent_category_params = json_decode($item->params);
  $categories = JCategories::getInstance('Content');
  // get child category ids
  $child_category_id = $categories->get($parent_category_id);
  // get child category object
  $child_category = $child_category_id->getChildren();

  /* Get a list of child categories with title and link */
?>
  <ul>
  <?php foreach ($child_category as $key => $value) : ?>
    <li><a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($value->id)); ?>"><?php echo $value->title; ?></a></li>
  <?php endforeach; ?>
  </ul>
<?php  
}
?>

以上是关于php 获取Joomla模块中的com_content类别的主要内容,如果未能解决你的问题,请参考以下文章