/**
* Count the number of child menu items of the current active menu item
*
* @return integer Number of child menu items
*
* @since 1.7.0
*/
public function countMenuChildren()
{
static $children;
if (!isset($children)) {
$db = CmsFactory::getDbo();
$app = CmsFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$children = 0;
if ($active) {
$query = $db->getQuery(true)->select('COUNT(*)')->from($db->quoteName('#__menu'))->where([$db->quoteName('parent_id') . ' = :id', $db->quoteName('published') . ' = 1'])->bind(':id', $active->id, ParameterType::INTEGER);
$db->setQuery($query);
$children = $db->loadResult();
}
}
return $children;
}