$categories = new JCategories(array('extension' => 'com_content', 'table' => '#__content'));
print_r($categories->get('root'));
Joomla\CMS\Categories\CategoryNode Object
(
[id] => root
[asset_id] => 0
[parent_id] => 0
...
Resource 'Joomla\CMS\Categories\DatabaseInterface' has not been registered with the container.
Latest nightly
These packages were last built: Wednesday, 13 July 2022 00:11:27 UTC
Can be fixed by calling $categories->setDatabase(JFactory::getDbo());
but that seems a B/C break. Code works on Joomla! 4.1.5 fine.
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Information Required
|
It's just an example. Obivously it's an extension that uses the Categories class but that's not the point.
Here, use this code which is according to the docs:
use Joomla\CMS\Categories\Categories;
class TestCategories extends Categories
{
public function __construct($options = array())
{
$options['table'] = '#__test_items';
$options['extension'] = 'com_test';
$options['statefield'] = 'published';
parent::__construct($options);
}
}
$categories = JCategories::getInstance('Test');
var_dump($categories->get('root'));
0 Resource 'Joomla\CMS\Categories\DatabaseInterface' has not been registered with the container.
object(Joomla\CMS\Categories\CategoryNode)[894]
Found it
and?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-07-13 17:11:40 |
Closed_By | ⇒ | OctavianC |
Where did you find this line? Which Version of Joomla, which Version of which extension?
$categories = new JCategories(array('extension' => 'com_content', 'table' => '#__content'));``