Permalink
Browse files

# [#29558] Incorrect current menu item highlighting in mod_menu if

'Base Item' is not current. Thanks Dennis
  • Loading branch information...
1 parent 0f8d8f0 commit b4c77d71f684d6d66ade21b309150daf9fc44ee3 @Denitz Denitz committed with infograf768 Nov 14, 2012
Showing with 47 additions and 21 deletions.
  1. +3 −0 installation/CHANGELOG
  2. +39 −18 modules/mod_menu/helper.php
  3. +4 −2 modules/mod_menu/mod_menu.php
  4. +1 −1 modules/mod_menu/mod_menu.xml
View
3 installation/CHANGELOG
@@ -26,6 +26,9 @@ $ -> Language fix or change
- -> Removed
! -> Note
+14-Nov-2012 Jean-Marie Simonet
+ # [#29558] Incorrect current menu item highlighting in mod_menu if 'Base Item' is not current. Thanks Dennis
+
13-Nov-2012 Jean-Marie Simonet
#$ [#29669] Consistent form validation notifications. Thanks Roland
# [#29675] *Protostar error page tries to load search module even when module is not published
View
57 modules/mod_menu/helper.php
@@ -21,9 +21,10 @@ class modMenuHelper
/**
* Get a list of the menu items.
*
- * @param JRegistry $params The module options.
+ * @param JRegistry $params The module options.
+ *
+ * @return array
*
- * @return array
* @since 1.5
*/
public static function getList(&$params)
@@ -50,7 +51,7 @@ public static function getList(&$params)
if ($items)
{
- foreach($items as $i => $item)
+ foreach ($items as $i => $item)
{
if (($start && $start > $item->level)
|| ($end && $item->level > $end)
@@ -143,30 +144,50 @@ public static function getList(&$params)
}
/**
- * Get active menu item.
+ * Get base menu item.
+ *
+ * @param JRegistry $params The module options.
*
- * @param JRegistry $params The module options.
+ * @return object
*
- * @return object
- * @since 3.0
+ * @since 3.0.2
*/
- public static function getActive(&$params)
+ public static function getBase(&$params)
{
- $menu = JFactory::getApplication()->getMenu();
- // Get active menu item from parameters
- if ($params->get('active')) {
- $active = $menu->getItem($params->get('active'));
- } else {
- $active = false;
+ // Get base menu item from parameters
+ if ($params->get('base'))
+ {
+ $base = JFactory::getApplication()->getMenu()->getItem($params->get('base'));
+ }
+ else
+ {
+ $base = false;
}
- // If no active menu, use current or default
- if (!$active) {
- $active = ($menu->getActive()) ? $menu->getActive() : $menu->getDefault();
+ // Use active menu item if no base found
+ if (!$base)
+ {
+ $base = self::getActive($params);
}
- return $active;
+ return $base;
+ }
+
+ /**
+ * Get active menu item.
+ *
+ * @param JRegistry $params The module options.
+ *
+ * @return object
+ *
+ * @since 3.0.2
+ */
+ public static function getActive(&$params)
+ {
+ $menu = JFactory::getApplication()->getMenu();
+
+ return $menu->getActive() ? $menu->getActive() : $menu->getDefault();
}
}
View
6 modules/mod_menu/mod_menu.php
@@ -13,13 +13,15 @@
require_once __DIR__ . '/helper.php';
$list = modMenuHelper::getList($params);
+$base = modMenuHelper::getBase($params);
$active = modMenuHelper::getActive($params);
$active_id = $active->id;
-$path = $active->tree;
+$path = $base->tree;
$showAll = $params->get('showAllChildren');
$class_sfx = htmlspecialchars($params->get('class_sfx'));
-if(count($list)) {
+if (count($list))
+{
require JModuleHelper::getLayoutPath('mod_menu', $params->get('layout', 'default'));
}
View
2 modules/mod_menu/mod_menu.xml
@@ -33,7 +33,7 @@
label="MOD_MENU_FIELD_MENUTYPE_LABEL"
description="MOD_MENU_FIELD_MENUTYPE_DESC" />
<field
- name="active"
+ name="base"
type="menuitem"
label="MOD_MENU_FIELD_ACTIVE_LABEL"
description="MOD_MENU_FIELD_ACTIVE_DESC"

0 comments on commit b4c77d7

Please sign in to comment.