Get current article category ID (catid) in Joomla 3.2

I need to get current article category id, in older joomla version I used:

<?php $catid = JRequest::getInt('catid'); echo $catid; ?>

But in Joomla 3.2 I get 0.

You can eliminate the extra database query by taking advantage of the fact that the article model instance is cached and so is the query result for the current article. So, use the content model class to get what you are after.

    $app = Jfactory::getApplication();
    $input=$app->input;
    if ($input->getCmd('option')=='com_content' 
    && $input->getCmd('view')=='article' ){
        $cmodel = JModelLegacy::getInstance('Article', 'ContentModel');
        $catid = $cmodel->getItem($app->input->get('id'))->catid;
    }

NB if you are calling this from a system plugin before the application is rendered you will have to also have to use require_once to include the content model. The above code will work fine in in most situations such as a template or content plugin.

get current category id in Joomla 3 - Joomla! Forum, I need to get current article category id, in older joomla version I used: <?php $​catid = JRequest::getInt('catid'); echo $catid; ?> But in Joomla 3.2 I get 0. You can​  In joomla 3 the category id is not in the www-query when you display an article. So you need to get it from the article item. To investigate if catid is available in some of your variables, you could try to do:

Try this

<?php echo $this->item->catid;?>

This work in blog_item.php the category folder, and blog.php of article folder.

Joomla show content if current article category id is, Can't find a method for just getting the catid of the current page. which view do you want to get category Id? ( view category or view article ). Begin with the Introduction, and navigate the articles in this series by using the navigation button at the bottom or the box to the right (the Articles in this series). Introduction. This tutorial is part of the Developing an MVC Component for Joomla! 3.2 tutorial. You are encouraged to read the previous parts of the tutorial before reading this.

I know this is an old post but, it helped me figure out just what I needed.

To get the catid, view, and layout:

$a = JFactory::getApplication();
 $input=$a->input;

 $catId = $input->getCmd('id');
 $view  = $input->getCmd('view');
 $layout = $input->getCmd('layout');

jd_chicago/article.php at master · joomdev/jd_chicago · GitHub, i am using joomla 2.5 and i want to show some special text only in those articles which belongs to category id 11. to get category id i tried: <?php $catid  The Flexible Platform Empowering Website Creators. We have detected that you are using an ad blocker. The Joomla! Project relies on revenue from these advertisements so

It will depend on your context. In joomla 3 the category id is not in the www-query when you display an article. So you need to get it from the article item. To investigate if catid is available in some of your variables, you could try to do:

<?php print_r($this); ?>

or

<?php print_r(get_defined_vars()); ?>

To get the catid directly in the template, if it's not available in the output above, you might do something like this:

$input=Jfactory::getApplication()->input;
if($input->getCmd('option')=='com_content' 
&& $input->getCmd('view')=='article' ){
  $db=JFactory::getDbo(); 
  $db->setQuery('select catid from #__content where id='.$input->getInt('id')); 
  $catid=$db->loadResult(); 
}

(this will generate some extra database-traffic) regards Jonas

Joomla global options SEF - joomla, JD Chicago template for Joomla. @since 3.2. */ Batch copy items to a new category or current. Get the new item ID Default to component settings if neither article nor category known. else Create new category and get catid back. Mini Frontpage is an advanced news display module for Joomla. It displays the joomla articles from selected categories with date, thumbnail, excerpt in various design and layout. It’s simple and easy to use. It also comes with many parameters to configure, to help you to create a good looking news block for your Joomla website quickly.

Articles Field - Tutorial, i need to get current article category id, in older joomla version i used: <?php $​catid = JRequest::getInt('catid'); echo $catid; ?> But in Joomla 3.2 i get 0. You can​  I searched google and read many articles but no luck, is there a way to get the link of a category for joomla 3.3.6 item/article. More details: I'm building a custom theme on Joomla 3.3.6 I have managed to display articles in the main page as thumbnails and inside these thumbnails image, description ,read more link and category, the read more

How to get the link of a category for item, Last updated: 28 Mar 2020; Version: 3.2.0; Type: Custom Field plugin; Joomla rating: 97% Articles Field by Regular Labs is a Joomla! custom field plugin that greatly to only display articles linking to the current article via certain "Articles" fields. Full Text of the article; [catid] the ID of the Category attached to the article​  WARNING: Users should upgrade to this release 3.2.6 of Attachments which fixes a SQL injection vulnerability in the previous release. Updates in this release are shown at the bottom of this page. Attachments, by Jonathan Cameron - Joomla Extension Directory

Displaying items by tag: jbackend, Use ContentHelperRoute to get article category url. It can be one like this this article view: Introduction. This tutorial is part of the Developing an MVC Component for Joomla! 3.2 tutorial. You are encouraged to read the previous parts of the tutorial before reading this. In this step we provide the ability for administrator to control the display of the category on the front end.

Comments
  • You need to get it in what context? For example in the layout? Or in the model? Or a plugin or helper?