继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

Drupal hook_view 来设置当前位置网站导航菜单,重写面包屑

我想实现,让别人点击具体产品的时候,然后出现您的当前位置的菜单,参考了drupal自带的模块代码,实现了我想要的功能。
比如查看IBM-T40的具体形式的时候,然后出现当前位置导航菜单:主页-笔记本-IBM-T40 这样的效果。
具体的代码如下:

<?php
/**
* Implementation of hook_view(). 当前位置导航
*/
function product_view($node, $teaser = FALSE, $page = FALSE) {
  if (
$page) {
   
// Breadcrumb navigation. l() escapes the title, so we should not escape !name.
   
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Product list'), 'product'), l(t("!name", array('!name' => $node->title)), 'node/'. $node->nid))); //drupal_set_breadcrumb 这个大概就是重写了当前位置导航,里面的l函数可以具体参考API 就是衔接,大概l就是link的简写吧
 
 
}

    if (
$teaser) {
   
// Breadcrumb navigation. l() escapes the title, so we should not escape !name.
   
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Product list'), 'product')));
    
  }
  return
node_prepare($node, $teaser);
}
?>

忙到现在,发现学习一下drupal自带的模块,会学习到很多经验。先模仿吧,然后提升!:)

评论

写在哪里

你这个函数是写在 主题下的 template.php 还是自定义模块中呢 ?

我这个主要是对product模块(我自己写的内容类型模块)

我这个主要是对product模块(我自己写的内容类型模块) 的菜单重写。写在模块里面的。

楼主 有没有qq 群 啊? ?

楼主 有没有qq 群 啊? ?

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.