JCategoryNode

Extends \JObject

Helper class to load Categorytree

This class allows for simple but smart objects with get and set methods and an internal error handler.

since

1.6

package

Joomla.Legacy

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed $properties = null) 
inherited
since

11.1

Arguments

$properties

mixedEither and associative array or another object to set the initial properties of the object.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

addChild

Add child to this node

addChild(\JCategoryNode $child) : void

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

since

1.6

Arguments

$child

\JCategoryNodeThe child to be added.

def

Sets a default value if not already assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixed

get

Returns a property of the object or the default value if the property is not set.

get(string $property, mixed $default = null) : mixed
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getAuthor

Returns the user that created the category

getAuthor(boolean $modified_user = false) : \JUser
since

1.6

Arguments

$modified_user

booleanReturns the modified_user when set to true

Response

\JUserA JUser object containing a userid

getChildren

Get the children of this node

getChildren(boolean $recursive = false) : array<mixed,\JCategoryNode>
since

1.6

Arguments

$recursive

booleanFalse by default

Response

array<mixed,\JCategoryNode>The children

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getNumItems

Returns the number of items.

getNumItems(boolean $recursive = false) : integer
since

1.6

Arguments

$recursive

booleanIf false number of children, if true number of descendants

Response

integerNumber of children or descendants

getParams

Returns the category parameters

getParams() : \Joomla\Registry\Registry
since

1.6

Response

\Joomla\Registry\Registry

getParent

Get the parent of this node

getParent() : \JCategoryNode
since

1.6

Response

\JCategoryNode

getPath

Returns the category path to the root category

getPath() : array
since

1.6

Response

array

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

getSibling

Returns the right or left sibling of a category

getSibling(boolean $right = true) : \JCategoryNode|null
since

1.6

Arguments

$right

booleanIf set to false, returns the left sibling

Response

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

hasChildren

Test if this node has children

hasChildren() : boolean
since

1.6

Response

booleanTrue if there is a child

hasParent

Test if this node has a parent

hasParent() : boolean
since

1.6

Response

booleanTrue if there is a parent

removeChild

Remove a specific child

removeChild(integer $id) : void
since

1.6

Arguments

$id

integerID of a category

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setAllLoaded

Set to load all children

setAllLoaded() : void
since

1.6

setError

Add an error message.

setError(string $error) : void
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setParent

Set the parent of this category

setParent(\JCategoryNode|null $parent) : void

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

since

1.6

Arguments

$parent

\JCategoryNode|nullJCategoryNode for the parent to be set or null

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither an associative array or another object.

Response

boolean

setSibling

Function to set the left or right sibling of a category

setSibling(\JCategoryNode $sibling, boolean $right = true) : void
since

1.6

Arguments

$sibling

\JCategoryNodeJCategoryNode object for the sibling

$right

booleanIf set to false, the sibling is the left one

Properties

id

Primary key

Type(s)

integer

asset_id

The id of the category in the asset table

Type(s)

integer

parent_id

The id of the parent of category in the asset table, 0 for category root

Type(s)

integer

lft

The lft value for this category in the category tree

Type(s)

integer

rgt

The rgt value for this category in the category tree

Type(s)

integer

level

The depth of this category's position in the category tree

Type(s)

integer

extension

The extension this category is associated with

Type(s)

integer

title

The menu title for the category (a short name)

Type(s)

string

alias

The the alias for the category

Type(s)

string

description

Description of the category.

Type(s)

string

published

The publication status of the category

Type(s)

boolean

checked_out

Whether the category is or is not checked out

Type(s)

boolean

checked_out_time

The time at which the category was checked out

Type(s)

string

access

Access level for the category

Type(s)

integer

params

JSON string of parameters

Type(s)

string

metadesc

Metadata description

Type(s)

string

metakey

Key words for meta data

Type(s)

string

created_user_id

The ID of the user who created the category

Type(s)

integer

created_time

The time at which the category was created

Type(s)

string

modified_user_id

The ID of the user who last modified the category

Type(s)

integer

modified_time

The time at which the category was modified

Type(s)

string

hits

Nmber of times the category has been viewed

Type(s)

integer

language

The language for the category in xx-XX format

Type(s)

string

numitems

Number of items in this category or descendants of this category

Type(s)

integer

childrennumitems

Number of children items

Type(s)

integer

slug

Slug fo the category (used in URL)

Type(s)

string

assets

Array of assets

Type(s)

array

_parent

Parent Category object

Type(s)

\JCategoryNode

_children

Array of Children

Type(s)

array<mixed,\JCategoryNode>

_path

Path from root to this category

Type(s)

array

_leftSibling

Category left of this one

Type(s)

\JCategoryNode

_rightSibling

Category right of this one

Type(s)

\JCategoryNode

_allChildrenloaded

Flag if all children have been loaded

Type(s)

boolean

_constructor

Constructor of this tree

Type(s)

\JCategoryNode

_errors

An array of error messages or Exception objects.

inherited deprecated

Type(s)

array