试图在博客页面上获取类别ID(Trying to get category id on blog page)
我试图通过以下方式获取每个帖子的类别ID:
$catid = JRequest::getInt('catid');我把这个脚本放在blog_item.php上
但我对所有帖子只有0
I'm trying to get category id of each post with this:
$catid = JRequest::getInt('catid');I put this script on blog_item.php
But I get only 0 to all posts
最满意答案
模板加载了ContentViewCategory的上下文。 它只允许一个主要类别,并且可以通过使用以下方式获取其id:
$mainCatid = $this->category->id可以通过查询项目的catid属性来获取当前项目的直接父项ID。 还有很多其他可用的属性,包括类别名称。
$catid = $this->item->catidThe template is loaded with the context of a ContentViewCategory. It allows only one main category, and its id can be obtained by using:
$mainCatid = $this->category->idThe current item's immediate parent's id can be obtained by querying the item's catid property. There are plenty of other properties available, including category name.
$catid = $this->item->catid
更多推荐
发布评论