diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-17 11:33:17 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-17 11:33:17 +0000 |
commit | 7420e77cdd5018235423bb065c41c5d8b0de7875 (patch) | |
tree | d22f7a66c82f8afb543bd8eea1b0427154caaf4c /engine/lib/views.php | |
parent | 30738f48bf92bd7b30a724232277b9c867174ae1 (diff) | |
download | elgg-7420e77cdd5018235423bb065c41c5d8b0de7875.tar.gz elgg-7420e77cdd5018235423bb065c41c5d8b0de7875.tar.bz2 |
Refs #2320 added new menu functions and classes
git-svn-id: http://code.elgg.org/elgg/trunk@7655 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/views.php')
-rw-r--r-- | engine/lib/views.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/engine/lib/views.php b/engine/lib/views.php index ade5ff678..71922cb6c 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -644,6 +644,43 @@ function elgg_view_layout($layout_name, $vars = array()) { } /** + * Render a menu + * + * @param string $menu_name The name of the menu + * @param array $vars An associative array of display options for the menu. + * Options include: + * sort_by => string or php callback + * string options: 'name', 'title' (default), 'order' (registration order) + * php callback: a compare function for usort + * + * @return string + * @since 1.8.0 + */ +function elgg_view_menu($menu_name, array $vars = array()) { + + $vars['name'] = $menu_name; + + $sort_by = elgg_get_array_value('sort_by', $vars, 'title'); + + // Give plugins a chance to add menu items just before creation. + // This supports context sensitive menus (ex. user hover). + elgg_trigger_plugin_hook('register', "menu:$menu_name", $vars, NULL); + + $builder = new ElggMenuBuilder($menu_name); + $vars['menu'] = $builder->getMenu($sort_by); + $vars['selected_item'] = $builder->getSelected(); + + // Let plugins modify the menu + $vars['menu'] = elgg_trigger_plugin_hook('prepare', "menu:$menu_name", $vars, $vars['menu']); + + if (elgg_view_exists("navigation/menu/$menu_name")) { + return elgg_view("navigation/menu/$menu_name", $vars); + } else { + return elgg_view("navigation/menu/default", $vars); + } +} + +/** * Returns a string of a rendered entity. * * Entity views are either determined by setting the view property on the entity |