试图在博客页面上获取类别ID(Trying to get category id on blog page)

编程入门 行业动态 更新时间:2024-10-23 10:18:59
试图在博客页面上获取类别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->catid

The 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->id
 

The 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

                    
                     
          

更多推荐

本文发布于:2023-08-05 19:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1438033.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类别   页面   博客   ID   page

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!