← Back to team overview

phpdevshell team mailing list archive

[Bug 894291] Re: Improvement to menu href link generation logic

 

If this is not going to break anything else I think the mod_menu_a()
function could simply be changed to this (notice I removed the checks
for hidden menu's on the 4'th line:

function mod_menu_a($mr, $class='')
{
	// Check if we have a place marker.
	if ($mr['menu_type'] == 6) {
		$noclick = 'onclick="return false;"';
		// Create URL.
		$url = "#";
	} else {
		$noclick = '';
		// Last check if it is a link item that should be jumped to.
		if ($mr['menu_type'] == 5) {
			$url = $mr['menu_link'];
		} else {
			$url = $mr['href'];
		}
	}
	($mr['new_window'] == 1) ? $target = '_blank' : $target = '_self';
	
	/**
	 * Class types:
	 * nav-grand
	 * nav-parent
	 * child
	 */
	if (empty($class))
		$span = '';
	else 
		$span = "<span class=\"{$class}\"></span>
		";

	return "<a href=\"{$url}\" target=\"{$target}\" {$noclick}>
				{$span}{$mr['menu_name']}
			</a>
			";
}

-- 
You received this bug notification because you are a member of
PHPDevShell, which is subscribed to PHPDevShell.
https://bugs.launchpad.net/bugs/894291

Title:
  Improvement to menu href link generation logic

Status in Open Source PHP RAD Framework with UI.:
  Confirmed

Bug description:
  An improvement may need to be made to the mod_menu_a() function in the
  mods.php files under the themes files.

  Lets give an example of the problem first:
  Imagine you would like to create a new menu item called "Home". This menu item is not going to be placed somewhere in the menu's itself but is going to be a button somewhere on your page. So you are going to Hide it from the top menu. The "Home" menu also simply references/links to an existing menu, let's say "Dashboard". So the way you are going to configure the Home menu is:

  1) Under Select Node Type: Set the menu to: (3) Jump to Link: Dashboard
  2) Hide Menu: "From All" or "From Menu Only"

  The problem comes in when you would like to render the a href tag for this link in your own theme. One would typically use the mod_menu_a() function in the mods.php file to do this. The problem is that mod_menu_a() thinks that this menu item is simply a place marker and therefore renders the <a href> tag as:
  target="_self"
  instead of rendering the real target for the menu.

  The problem with this is that it is assumed that when a menu item is hidden from all, or from the menu itself, that it is a self referencing link and this may not always be the case. Of course one can simply change the mod_menu_a() function to suite your needs better but it takes a while for one to figure out what is going on and why your menu isn't working as it should. In my case for example I had to change the line:
  if ($mr['menu_type'] == 6 || ($mr['hide'] != 0 && $mr['hide'] != 2))

  to

  if ($mr['menu_type'] == 6 || ($mr['menu_type'] != 3 &&  $mr['hide'] !=
  0 && $mr['hide'] != 2))

  The question is, can mod_menu_a() be improved to handle this situation
  better by default or is it going to cause problems elsewhere?

To manage notifications about this bug go to:
https://bugs.launchpad.net/phpdevshell/+bug/894291/+subscriptions


References