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类别的主要内容,如果未能解决你的问题,请参考以下文章

在 joomla 组件中传递获取变量

如何在joomla中建立链接

在为 Joomla 1.5.26 修复 Virtuemart 1.1.9 的 Flex2 运输模块中的错误时出现 PHP 范围问题

Joomla 中的模块只调用一次

将 Joomla 模块放在 index.php 之外

Joomla 组件中的 PHP MVC