跳至内容
Python 俱乐部
用户工具
登录
站点工具
搜索
工具
显示页面
修订记录
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
drupal:script:node_type
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
====== Drupal 判断当前页面类型 ====== 在Drupal中,分类系统路径都是类似这种格式: taxonomy/term/10 taxonomy/term/17 那么,根据Drupal API,判断当前页面为分类页面,可以这样写: <code> if ( arg(0) == "taxonomy" && arg(1) == "term" ) { echo "这是分类"; } else { echo "这不是分类"; } </code> 类似,节点(node)在drupal内部路径为 node/1, 使用下面的代码可以判断是否为节点(node)。 <code php> <?php $retArgs = array (); if( arg(0) == 'node' && is_numeric(arg(1) ) ){ $nid = arg(1); //$node = node_load($nid); $retArgs[] = $nid; $tids = ''; $vid = 2; // this is the vocabulary id to search through... $terms = taxonomy_node_get_terms_by_vocabulary($nid, $vid); foreach($terms as $term){ $tids[] = $term->tid; } if ($terms) $tids = implode('+', $tids); $retArgs[] = $tids; } return $retArgs; ?> </code>
drupal/script/node_type.txt
· 最后更改: 2010/06/02 01:18 (外部编辑)
页面工具
显示页面
修订记录
反向链接
回到顶部