API15

Difference between revisions of "JCategories/get"

From Joomla! Documentation

< API15:JCategories
(New page: ===Description=== Loads a specific category and all its children in a JCategoryNode object <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JCategori...)
 
m (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JCategories/get|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JCategories/get}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 53: Line 53:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JCategories/get|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JCategories/get}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 68: Line 68:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Revision as of 08:51, 12 May 2013

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

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[edit]

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

Returns[edit]

Defined in[edit]

libraries/joomla/application/categories.php

Importing[edit]

jimport( 'joomla.application.categories' );

Source Body[edit]

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[edit]

<CodeExamplesForm />

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

===Description===

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


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

Syntax[edit]

get($id='root', $options=array())
Parameter Name Default Value Description
$id 'root' optional id integer or equal to 'root'
$options array() optional array of boolean options (all set to true by default). 'load' to force loading 'children' to get its direct children, 'parent' to get its direct parent, 'siblings' to get its siblings 'ascendants' to get its ascendants 'descentants' to get its descendants 'level-min' to get nodes from this level 'level-max' to get nodes until this level

Returns[edit]

JCategoryNode|null

Defined in[edit]

libraries/joomla/application/categories.php

Importing[edit]

jimport( 'joomla.application.categories' );

Source Body[edit]

public function get($id='root',$options=array())
{
        if ($id != 'root')
        {
                $id = (int) $id;
                if ($id == 0)
                {
                        return null;
                }
        }
        if (!isset($this->_nodes[$id]) || !isset($options['load']) || $options['load'])
        {
                $this->_load($id,$options);
        }
        
        return $this->node($id);
}


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

Examples[edit]

Code Examples[edit]

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