不是链接的Drupal菜单项

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了不是链接的Drupal菜单项相关的知识,希望对你有一定的参考价值。

This snippet allows admins to create menu items which do not link anywhere. This is most useful in situations where one wants to have dropdown menus where the parent item should not be a link.

This same method could be used to create non-linking menu divider/headings.

Use http://fake.link for every menu item that should not be linkable.

Also, consider using http://drupal.org/project/special_menu_items to provide this capability.
  1. <?php
  2. function THEMENAME_menu_item_link($link) {
  3. if (empty($link['localized_options'])) {
  4. $link['localized_options'] = array();
  5. }
  6.  
  7. if (!$link['page_callback'] && strpos( $link['href'], 'fake.link')) {
  8. return '<a href="javascript:void(0)" onclick="return false" class="nolink">'. $link['title'] .'</a>';
  9. }
  10. else {
  11. return l($link['title'], $link['href'], $link['localized_options']);
  12. }
  13. }
  14. ?>

以上是关于不是链接的Drupal菜单项的主要内容,如果未能解决你的问题,请参考以下文章

Drupal 限制主链接中菜单项的数量

获取 Drupal 中当前提供的路由的菜单链接项

PHP Drupal菜单不是链接的项目

如何在Drupal 8菜单项中添加额外的字段。我想添加一个额外的图像字段

Drupal:如何动态设置活动菜单项

PHP 向Drupal菜单项添加唯一ID