Answer the question
In order to leave comments, you need to log in
How to get category instance for your component in Joomla?
Good time. There was a strange problem: I'm trying to get a category instance for my component, according to the docs, I use the following code for this:
jimport( 'joomla.application.categories' );
$categories = JCategories::getInstance('Mycomponent');
Answer the question
In order to leave comments, you need to log in
In the component, in order to be able to get an instance, you need to create a helper class that inherits the required parent. For categories it will be /helpers/category.php with content
class MycomponentCategories extends JCategories {
public function __construct($options = array()) {
$options['table'] = '#__mytable';
$options['extension'] = 'com_mycomponent';
parent::__construct($options);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question