[FIXED] mod_mainmenu helper notice when showing subtree with no active parent

Locked
trevornorth
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 07, 2007 10:08 pm

[FIXED] mod_mainmenu helper notice when showing subtree with no active parent

Post by trevornorth » Fri Jan 04, 2008 12:37 pm

The mod_mainmenu helper generates a notice if trying to show a sub-menu tree (i.e. starting at level 2) if there is no currently active menu item.

A simple fix is as follows (new lines prefixed with !):

Code: Select all

function &getXML($type, &$params, $decorator)
{
(..)
	// Get subtree
	if ($start)
	{
!		if (!isset($active)) {
!			$doc = false;
!		} else {
			$found = false;
			$root = true;
			$path = $active->tree;
			for ($i=0,$n=count($path);$ichildren() as $child)
				{
					if ($child->attributes('id') == $path[$i]) {
						$doc = &$child->ul[0];
						$root = false;
						break;
					}
				}

				if ($i == $start-1) {
					$found = true;
					break;
				}
			}
			if ((!is_a($doc, 'JSimpleXMLElement')) || (!$found) || ($root)) {
				$doc = false;
			}
!		}
	}
(..)
}

 
User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 18964
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: mod_mainmenu helper notice when showing subtree with no active parent

Post by infograf768 » Fri Jan 04, 2008 1:30 pm

Thanks a lot for your code fixes (here and your other posts). :)

I made sure devs are aware of these and can hopefully test/commit asap.
Jean-Marie Simonet / infograf · http://www.info-graf.fr
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

mtk
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Sat Nov 12, 2005 10:55 pm
Location: Israel
Contact:

Re: mod_mainmenu helper notice when showing subtree with no active parent

Post by mtk » Fri Jan 04, 2008 6:33 pm

@trevornorth,
can you tell us specific step to reproduce thie NOTICE you're getting (so we could verify the fix)?
"In a world without walls and fences,
who needs Windows & Gates?"

http://www.smartmtk.com | http://www.lighthost.co.il/webhosting-for-joomla

trevornorth
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 07, 2007 10:08 pm

Re: mod_mainmenu helper notice when showing subtree with no active parent

Post by trevornorth » Sat Jan 05, 2008 11:54 am

Take a menu with the following structure:
Menu Item 1
- Sub Menu Item
Menu Item 2

And two mod_mainmenu modules showing it with the following start and end levels respectively:
Primary nav - Start Level 0, End Level 1
Secondary nav - Start Level 1, End Level 0

When 'Menu Item 1' is active, the secondary nav would show 'Sub Menu Item'.  When 'Menu Item 2' is active the secondary nav would be empty.

However, if we do not have an active menu item the secondary nav module will throw a notice on line 97.  This will occur in any instance where a component is shown directly, without navigating via a menu item (e.g. when performing a search from the mod_search module).  For example, the notice will be shown on the following page:
http://mysite.com/component/search/test
(assuming SEF and mod_rewrite)

Hope that clarifies.

mtk
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Sat Nov 12, 2005 10:55 pm
Location: Israel
Contact:

Re: mod_mainmenu helper notice when showing subtree with no active parent

Post by mtk » Sat Jan 05, 2008 12:39 pm

Thanks, it is now fixed in SVN
"In a world without walls and fences,
who needs Windows & Gates?"

http://www.smartmtk.com | http://www.lighthost.co.il/webhosting-for-joomla

 

Locked

Return to “Q&T 1.5.x Resolved”