本文整理汇总了PHP中ElggMenuItem::getChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggMenuItem::getChildren方法的具体用法?PHP ElggMenuItem::getChildren怎么用?PHP ElggMenuItem::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggMenuItem
的用法示例。
在下文中一共展示了ElggMenuItem::getChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: orderMenuItem
/**
* Reorders menu item and adds an add button
*
* @param \ElggMenuItem $item menu item
* @param int $depth depth of the menu item
*
* @return \ElggMenuItem
*/
private static function orderMenuItem(\ElggMenuItem $item, $depth)
{
$depth = (int) $depth;
$children = $item->getChildren();
if (empty($children)) {
return $item;
}
// sort children
$ordered_children = [];
foreach ($children as $child) {
$child = self::orderMenuItem($child, $depth + 1);
$child_priority = $child->getPriority();
while (array_key_exists($child_priority, $ordered_children)) {
$child_priority++;
}
$ordered_children[$child_priority] = $child;
}
ksort($ordered_children);
$item->setChildren($ordered_children);
return $item;
}
示例2: theme_haarlem_add_toggle_link
/**
* Adds a toggle link for use in responsive
*
* @param \ElggMenuItem $item
*/
function theme_haarlem_add_toggle_link(\ElggMenuItem &$item)
{
$children = $item->getChildren();
if (empty($children)) {
return;
}
$item->setText($item->getText() . elgg_view_icon('angle-right', 'elgg-menu-site-toggle'));
foreach ($children as $child) {
theme_haarlem_add_toggle_link($child);
}
}
示例3: menu_builder_order_menu_item
/**
* Reorders menu item and adds an add button
*
* @param ElggMenuItem $item menu item
* @param int $depth depth of the menu item
*
* @return ElggMenuItem
*/
function menu_builder_order_menu_item(ElggMenuItem $item, $depth)
{
$depth = (int) $depth;
if ($children = $item->getChildren()) {
// sort children
$ordered_children = array();
foreach ($children as $child) {
$child = menu_builder_order_menu_item($child, $depth + 1);
$child_priority = $child->getPriority();
while (array_key_exists($child_priority, $ordered_children)) {
$child_priority++;
}
$ordered_children[$child_priority] = $child;
if (isset($_SESSION["menu_builder_edit_mode"]) && $depth < 5) {
// add button
$child_add = ElggMenuItem::factory(array("name" => 'menu_builder_add', "text" => elgg_view_icon("round-plus"), "href" => '/menu_builder/edit?parent_guid=' . $child->getName(), "class" => "menu_builder_add_link", "title" => elgg_echo("menu_builder:edit_mode:add")));
$child->addChild($child_add);
}
}
ksort($ordered_children);
$item->setChildren($ordered_children);
}
return $item;
}