Back to TagsHelper class

Method getTagTreeArray

public mixed
getTagTreeArray
(mixed $id, mixed &$tagTreeArray = array())
Method to get an array of tag ids for the current tag and its children
Parameters
  • int $id An optional ID
  • array & $tagTreeArray Array containing the tag tree
Returns
  • mixed
Since
  • 3.1
Class: TagsHelper
Project: Joomla

Method getTagTreeArray - Source code

/**
 * Method to get an array of tag ids for the current tag and its children
 *
 * @param   integer  $id             An optional ID
 * @param   array    &$tagTreeArray  Array containing the tag tree
 *
 * @return  mixed
 *
 * @since   3.1
 */
public function getTagTreeArray($id, &$tagTreeArray = array())
{
    // Get a level row instance.
    $table = Factory::getApplication()->bootComponent('com_tags')->getMVCFactory()->createTable('Tag', 'Administrator');
    if ($table->isLeaf($id)) {
        $tagTreeArray[] = $id;
        return $tagTreeArray;
    }
    $tagTree = $table->getTree($id);
    // Attempt to load the tree
    if ($tagTree) {
        foreach ($tagTree as $tag) {
            $tagTreeArray[] = $tag->id;
        }
        return $tagTreeArray;
    }
}