Hi I am trying to add rel="lightframe" to a specific menu item on my drupal site so that this external link opens within a lightbox frame. I'm by no means a php developer but this is what I have so far in my template.php file in my theme directory(fusion)

function fusion_menu_item_link($link) {
  if (! is_array($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if (! is_array($link['localized_options']['attributes'])) {
    $link['localized_options']['attributes'] = array();
  }
  if ($link['href'] == 'http://web.rgdirect.com/fusionmap/') {
    $link['localized_options']['attributes']['rel'] = 'lightframe';
  }
  return l($link['title'], $link['href'], $link['localized_options']);
}

Does anyone know what I'm missing? I honestly don't have any idea.

Thanks,

Comments

chris.mccreery’s picture

Forgot to mention that I am just trying to test for the one specific link item which I assumed the following was testing for:

if ($link['href'] == 'http://web.rgdirect.com/fusionmap/') {
    $link['localized_options']['attributes']['rel'] = 'lightframe';
  }

Thanks again,

dadderley’s picture

I believe that you can add the "rel" attribute to specific items in drupal menus using the http://drupal.org/project/menu_attributes module.
This does not answer your coding question, but it works and its easy.

chris.mccreery’s picture

Thank you so much, I just wasn't searching properly for modules I guess. Way easier. Thank you very much.

dadderley’s picture

You are welcome.