在用户可以编辑的节点上显示块?

wgr*_*erg 2 drupal drupal-6

什么块可见性PHP代码段仅在loged-in用户可以编辑的节点页面上显示块?用户可能不拥有该节点.在我的情况下,我想向可以实际填充缺失字段的人显示内容完成块.

Cap*_*iel 5

检查node_access("update",$ node)(更多信息,请访问http://api.drupal.org/api/function/node_access/6)

  //first check whether it is a node page
  if(arg(0) == 'node' && is_numeric(arg(1))){
    //load $node object
    $node = node_load(arg(1))
    //check for node update access
    if (node_access("update", $node)){
      return TRUE;
    }
  }

  //first check whether it is a node page
  if(arg(0) == 'node' && is_numeric(arg(1))){
    //load $node object
    $node = node_load(arg(1))
    //check for node update access
    if (node_access("update", $node)){
      return TRUE;
    }
  }

  • +1 - 一个直接的解决方案.我会用`return node_access("update",$ node)`替换if子句,但是;) (3认同)