Hello,

I would like to make one of the menu link items load a node upon rollover. In other words I have a page with multiple menu blocks on them, when someone rolls over that link, the expanded piece is actually the node_load instead of just a list of links.

I can get this to work on non-superfish menus, so was curious as to how or where superfish is overriding this ability.

Comments

TravisJohnston’s picture

Er, that may sound a little confusing so ill try and explain a little clearer.

I am using theme_links() to pull this in with an IF statement if $link['href'] = a certain nodeID then node_load()

The reasoning behind this is there is one section of the site that we heard is a little confusing to navigate, so I created a node that pulls in a few menu blocks set in columns. The idea is that when a user rolls over the primary menu, instead of going to the standard page and navigating through the menu, a node would load and display my custom page with all the menublocks.

TravisJohnston’s picture

Im getting closer kind of. I can get LI items in the node to load in, but not the body text nor the block invokes that I have in the template file.

So what I did was something like this below. You can see where I needed to add in the SuperFish menu classes in order to get it to start working, though I need to also have Superfish pull in the other link's children which it is not, and is only expanding the link to node 2551.

function phptemplate_links($links, $attributes = array('class' => 'menu_outer', 'sf-menu', 'sf-js-enabled')) {
  $queryArray = explode("/", $_GET['q']);
	
  $output = '';
	
  if (count($links) > 0) {
    $output = '<ul class="menu_outer sf-menu sf-js-enabled">';

    $num_links = count($links);
    $i = 1;
	  
    foreach ($links as $key => $link) {

    $class = $key;

    $class .= ' ';
      
      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= 'expanded item-odd first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      
      if( $link['href'] == "node/2551" )
	  {
	  	$class .= ' menuoption';
	  }
      	 
      $output .= '<li class="expanded item-odd">';

      if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        $output .= l($link['title'], $link['href'], $link);
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
      }

      
   	  if( $link['href'] == "node/2551" )
	  {
	  	  	
		$nodeData = node_load(2551);
	  	$rolloverData = include('node-program_rollover-2551.tpl.php');
		
	  	$output .= $nodeData->body;
	  	$output .= $rolloverData;
	  }
	  
      $i++;
      $output .= "</li>\n";
    }
  
    $output .= '</ul>';
  }

  return $output;
}

The include statement does load, but it places it outside of the menu. If I can get it to stay within the menu it would be all set.

TravisJohnston’s picture

Got it...


function phptemplate_menu_item_link($link) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
   
  if ($link['type'] && $link['href'] == 'node/2551') {
   
        $nodeID = node_load(2551);
        $nodeData = node_view($nodeID);
       
        $output .= '<a href="programs">' . $link['title'] . '</a>';
        $output .= '<ul>';
          $output .= $nodeData;
        $output .= '</ul>';
       
        return $output;
  }
  else {
    return l($link['title'], $link['href'], $link['localized_options']);
  }
}
Poieo’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

This seams like a superfish request, not Fusion.