aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-12-16 11:52:13 -0800
committerBrett Profitt <brett.profitt@gmail.com>2012-12-16 11:52:13 -0800
commitd719d03f1b0e636db021e728cf79a10176d991da (patch)
tree4a9c9b305c569ff3dfdc41a592e161527ae44e33
parent696bbe332b3011227e632459a7b8ac68b69a67b1 (diff)
parentb336f1065259b28113be1bca11dabe3ac167bd1a (diff)
downloadelgg-d719d03f1b0e636db021e728cf79a10176d991da.tar.gz
elgg-d719d03f1b0e636db021e728cf79a10176d991da.tar.bz2
Merge pull request #325 from beck24/#2845-site-menu-select-persistance
#2845 - persist 'selected' state of site menu
-rw-r--r--engine/lib/navigation.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 8c3952594..86624cd7c 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -308,6 +308,32 @@ function elgg_site_menu_setup($hook, $type, $return, $params) {
$return['more'] = array_splice($return['default'], $max_display_items);
}
}
+
+ // check if we have anything selected
+ $selected = false;
+ foreach ($return as $section_name => $section) {
+ foreach ($section as $key => $item) {
+ if ($item->getSelected()) {
+ $selected = true;
+ break 2;
+ }
+ }
+ }
+
+ if (!$selected) {
+ // nothing selected, match name to context
+ foreach ($return as $section_name => $section) {
+ foreach ($section as $key => $item) {
+ // only highlight internal links
+ if (strpos($item->getHref(), elgg_get_site_url()) === 0) {
+ if ($item->getName() == elgg_get_context()) {
+ $return[$section_name][$key]->setSelected(true);
+ break 2;
+ }
+ }
+ }
+ }
+ }
return $return;
}