API16

JTableNested/isLeaf

From Joomla! Documentation

< API16:JTableNested
Revision as of 02:11, 25 March 2017 by JoomlaWikiBot (talk | contribs) (preparing for archive only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API16" 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]

Method to determine if a node is a leaf node in the tree (has no children).



Syntax[edit]

isLeaf($pk=null)
Parameter Name Default Value Description
$pk null Primary key of the node to check.

Returns[edit]

boolean True if a leaf node.

Defined in[edit]

libraries/joomla/database/tablenested.php

Importing[edit]

jimport( 'joomla.database.tablenested' );

Source Body[edit]

public function isLeaf($pk = null)
{
        // Initialise variables.
        $k = $this->_tbl_key;
        $pk = (is_null($pk)) ? $this->$k : $pk;

        // Get the node by primary key.
        if (!$node = $this->_getNode($pk)) {
                // Error message set in getNode method.
                return false;
        }

        // The node is a leaf node.
        return (($node->rgt - $node->lft) == 1);
}



Examples[edit]

Code Examples[edit]