JTableNested/isLeaf: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 4: | Line 4: | ||
===Syntax=== | ===Syntax=== | ||
| Line 48: | Line 48: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=isLeaf | category=isLeaf | ||
category=JTableNested | category=JTableNested | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:11, 25 March 2017
Description
Method to determine if a node is a leaf node in the tree (has no children).
Syntax
isLeaf($pk=null)
| Parameter Name | Default Value | Description |
|---|---|---|
| $pk | null | Primary key of the node to check. |
Returns
boolean True if a leaf node.
Defined in
libraries/joomla/database/tablenested.php
Importing
jimport( 'joomla.database.tablenested' );
Source Body
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
Code Examples