Last active
February 23, 2016 19:04
-
-
Save mrclay/2242916 to your computer and use it in GitHub Desktop.
Manage arrays of Elgg menu items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function site_menu_prepare($h, $t, $v, $p) { | |
// wrap around the default menu | |
$list = new MenuList($v['default']); | |
// move "More" items into main | |
$list->appendList($v['more']); | |
unset($v['more']); | |
$list->remove('more'); | |
// remove a few things | |
$list->remove('videolist'); | |
$list->remove('blog'); | |
$list->remove('members'); | |
// alter an item | |
if ($item = $list->get('activity')) { | |
$item->setText(elgg_echo('_site:menu:activity')); | |
} | |
// move an item to the end | |
$list->move('file', -1); | |
// add an item in a position | |
if (!elgg_is_logged_in()) { | |
$list->move(new \ElggMenuItem('login', elgg_echo('login'), 'login'), 0); | |
} | |
// dump list back to $v | |
$v['default'] = $list->getItems(); | |
return $v; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment