class CategoryNode extends JObject

Helper class to load Categorytree

Properties

integer $id Primary key
integer $asset_id The id of the category in the asset table
integer $parent_id The id of the parent of category in the asset table, 0 for category root
integer $lft The lft value for this category in the category tree
integer $rgt The rgt value for this category in the category tree
integer $level The depth of this category's position in the category tree
integer $extension The extension this category is associated with
string $title The menu title for the category (a short name)
string $alias The the alias for the category
string $description Description of the category.
boolean $published The publication status of the category
boolean $checked_out Whether the category is or is not checked out
string $checked_out_time The time at which the category was checked out
integer $access Access level for the category
string $params JSON string of parameters
string $metadesc Metadata description
string $metakey Key words for metadata
string $metadata JSON string of other metadata
integer $created_user_id The ID of the user who created the category
string $created_time The time at which the category was created
integer $modified_user_id The ID of the user who last modified the category
string $modified_time The time at which the category was modified
integer $hits Nmber of times the category has been viewed
string $language The language for the category in xx-XX format
integer $numitems Number of items in this category or descendants of this category
integer $childrennumitems Number of children items
string $slug Slug fo the category (used in URL)
array $assets Array of assets

Methods

__construct( array $category = null, CategoryNode $constructor = null)

Class constructor

void
setParent( CategoryNode|null $parent)

Set the parent of this category

void
addChild( CategoryNode $child)

Add child to this node

void
removeChild( integer $id)

Remove a specific child

getChildren( boolean $recursive = false)

Get the children of this node

getParent()

Get the parent of this node

boolean
hasChildren()

Test if this node has children

boolean
hasParent()

Test if this node has a parent

void
setSibling( CategoryNode $sibling, boolean $right = true)

Function to set the left or right sibling of a category

getSibling( boolean $right = true)

Returns the right or left sibling of a category

Registry
getParams()

Returns the category parameters

Registry
getMetadata()

Returns the category metadata

array
getPath()

Returns the category path to the root category

JUser
getAuthor( boolean $modified_user = false)

Returns the user that created the category

void
setAllLoaded()

Set to load all children

integer
getNumItems( boolean $recursive = false)

Returns the number of items.

Details

__construct( array $category = null, CategoryNode $constructor = null)

Class constructor

Parameters

array $category The category data.
CategoryNode $constructor The tree constructor.

void setParent( CategoryNode|null $parent)

Set the parent of this category

If the category already has a parent, the link is unset

Parameters

CategoryNode|null $parent CategoryNode for the parent to be set or null

Return Value

void

void addChild( CategoryNode $child)

Add child to this node

If the child already has a parent, the link is unset

Parameters

CategoryNode $child The child to be added.

Return Value

void

void removeChild( integer $id)

Remove a specific child

Parameters

integer $id ID of a category

Return Value

void

CategoryNode[] getChildren( boolean $recursive = false)

Get the children of this node

Parameters

boolean $recursive False by default

Return Value

CategoryNode[] The children

CategoryNode getParent()

Get the parent of this node

Return Value

CategoryNode

boolean hasChildren()

Test if this node has children

Return Value

boolean True if there is a child

boolean hasParent()

Test if this node has a parent

Return Value

boolean True if there is a parent

void setSibling( CategoryNode $sibling, boolean $right = true)

Function to set the left or right sibling of a category

Parameters

CategoryNode $sibling CategoryNode object for the sibling
boolean $right If set to false, the sibling is the left one

Return Value

void

CategoryNode|null getSibling( boolean $right = true)

Returns the right or left sibling of a category

Parameters

boolean $right If set to false, returns the left sibling

Return Value

CategoryNode|null CategoryNode object with the sibling information or null if there is no sibling on that side.

Registry getParams()

Returns the category parameters

Return Value

Registry

Registry getMetadata()

Returns the category metadata

Return Value

Registry A Registry object containing the metadata

array getPath()

Returns the category path to the root category

Return Value

array

JUser getAuthor( boolean $modified_user = false)

Returns the user that created the category

Parameters

boolean $modified_user Returns the modified_user when set to true

Return Value

JUser A \JUser object containing a userid

void setAllLoaded()

Set to load all children

Return Value

void

integer getNumItems( boolean $recursive = false)

Returns the number of items.

Parameters

boolean $recursive If false number of children, if true number of descendants

Return Value

integer Number of children or descendants