From 289025b16464ecf8d1832ff49db3866f5aa40e1b Mon Sep 17 00:00:00 2001 From: grndlvl Date: Thu, 8 Sep 2011 23:54:00 -0400 Subject: [PATCH] Issue #586396 by grndlvl: Active Menu when menu is not primary or secondary links --- context.module | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/context.module b/context.module index 637ffd8..613cf98 100644 --- a/context.module +++ b/context.module @@ -179,6 +179,25 @@ function context_init() { } /** + * Implementation of hook_preprocess_menu_link(). + * + * This allows menus that are not primary/secondary menus to get + * the "active" class assigned to them. This assumes they are using + * theme('menu_link') for the menu rendering to html. + */ +function context_preprocess_menu_link(&$variables) { + if($contexts = context_active_contexts()){ + foreach($contexts as $context){ + if((isset($context->reactions['menu']))){ + if ($variables['element']['#href'] == $context->reactions['menu']) { + $variables['element']['#localized_options']['attributes']['class'][] = "active"; + } + } + } + } +} + +/** * Load & crud functions ============================================== */ -- 1.7.4.1