开发者

Make a visible primary link not clickable

开发者 https://www.devze.com 2023-01-14 01:15 出处:网络
On my Drupal site I\'ve got a set of Primary Links. The ones that expand I\'d like to make the parent not click able e.g

On my Drupal site I've got a set of Primary Links. The ones that expand I'd like to make the parent not click able e.g

  -home
  -about
    -history
    -website

Only home, history, website should link to a page. If the user clicks on aboutnothing should happen. I've tried searching around the admin panels as well as leaving the field blank but it doesn't seem开发者_运维问答 to be working. I'd assume I'd have to hardcode this? If so, how?


Try this module http://drupal.org/project/special_menu_items

Its probably the simplest way to achieve what you want.


If you can live with it, the easiest solution is to use js to disable clicks.


Adding a yourtheme_menu_item function in template.php seems to be the way to go for this. The documentation for the original function is at http://api.drupal.org/api/function/theme_menu_item

The function passes a $has_children variable and a $menu variable, so it should be pretty easy to adjust Primary Menu items with children as needed.

Some untested example code:

function yourtheme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  // ... original theme code copy-pasted ...
  if ($has_children) {
    $modified_link_name = youtheme_write_menu_item_without_links($link);
    return '<li class="'. $class .'">'. $modified_link_name ."</li>\n";
  } else {
    // From original function
    return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
  }
}


You just need to add in the path the phrase <nolink>.


"You just need to add in the path the phrase <nolink>" i used this before and it worked, but for some reason it didn´t work for a different site that i am using now. So i tried to write # in the path and worked fine for me.

Hug everybody.

0

精彩评论

暂无评论...
验证码 换一张
取 消