API15

API15:JCategories/get

From Joomla! Documentation

Description

Loads a specific category and all its children in a JCategoryNode object

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

get($id)
Parameter Name Default Value Description
$id

Returns

Defined in

libraries/joomla/application/categories.php

Importing

jimport( 'joomla.application.categories' );

Source Body

public function get($id)
{
        $id = (int) $id;
        if ($id == 0)
        {
                return false;
        }
        if (!isset($this->_nodes[$id]))
        {
                $this->_load($id);
        }
        if ($this->_nodes[$id] instanceof JCategoryNode)
        {
                return $this->_nodes[$id];
        } else {
                throw new JException('Unable to load category: '.$id, 0000, E_ERROR, $info, true);
        }
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples

need more info

hi, I am trying to use this go get all the subcategories of a certain category jimport('joomla.application.categories'); $categories = new JCategories('com_content'); print_r($categories); $subCategories = $categories->get(78); print_r($subCategories);

but this gives: JCategories Object ( [_nodes:protected] => [_checkedCategories:protected] => [_extension:protected] => c [_table:protected] => c [_field:protected] => c [_key:protected] => c [_statefield:protected] => c [_options:protected] => com_jumi ) subs:

So my guess is I can't acces the nessacary data because it is protected... any help?

Djemmers 07:56, 7 March 2011 (CST) Edit comment