Drupal6:从 hook_preprocess_page(&$vars) 访问节点信息
对于某种内容类型,我想更改访问被拒绝的错误消息。这样做的最佳方法是什么?
function mytheme_preprocess_page(&$vars) {
if ($vars['title'] == 'Access denied' && $node->type == 'ODP') {
$vars['content'] = 'OMG WHAT R U DOING!1!?!!1';
}
我希望能做这样的事情。但是,在 print_r(get_define_vars())
之后,我无法找到任何可以帮助我弄清楚所显示的节点是什么类型的内容。
For a certain content type, I want to alter the access denied error message. What is the best way to go about doing this?
function mytheme_preprocess_page(&$vars) {
if ($vars['title'] == 'Access denied' && $node->type == 'ODP') {
$vars['content'] = 'OMG WHAT R U DOING!1!?!!1';
}
I was hoping to do something like that. However, after a print_r(get_defined_vars())
, I was unable to find anything that could help me figure out what type the node being displayed is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为这是可以做到的 - Drupal 中的访问被拒绝消息是通过调用 drupal_access_denied()。如果您阅读链接的 API 条目,您会发现它没有传递有关正在访问的页面类型的任何信息。
I don't think that this can be done - an access denied message in Drupal is generated by calling drupal_access_denied(). If you read the linked API entry, you will see that it doesn't pass any information about what type of page was being visited.