欢迎各位兄弟 发布技术文章
这里的技术是共享的
  drupal定制首页有很多方法,可以用page--front.tpl.php模版定制首页,可以用views或者相关的模块,但是我们不免有需要判断drupal当前页面是否为首页的时候。
1  | if( $is_front ){ /* 首页代码 */ } | 
1 2 3 4  | if ( $node->type == 'blog' ) {include 'page-blog.tpl.php';return;} | 
1 2 3 4  | if ( arg(0) == 'admin' ) {include 'admin.tpl.php';return;} | 
1 2 3 4 5  | if ( $is_admin ) {/* 是管理员 */} else {/* 不是管理员 */} | 
1 2 3 4 5 6  | global $user;if ( in_array('guest',$user->roles) ) {/* 用户 guest 角色 */} else {/* 不是该角色 */} | 
1 2 3 4 5 6  | global $user;if ( $user->uid ) {/* 用户已经登陆 */} else {/* 用户没有登陆 */} | 
1 2 3 4 5  | if ( arg(0) == "taxonomy" && arg(1) == "term" ) {echo "这是分类";} else {echo "这不是分类";} | 
1 2 3 4 5  | if( arg(0)=='node' && is_numeric(arg(1)) ) {echo "这是节点";} else {echo "这不是节点";} | 
1 2 3 4 5  | if ( node_access('update', $node) ) {/* 具有编辑权限 */} else {/* 不可编辑该节点 */} |