【发布时间】:2011-12-13 15:20:28
【问题描述】:
[Drupal 6] 我的预处理函数是
function blogs_additions_preprocess_user_profile(&$variables) {
global $user;
$op = '';
$op .= l(t('Delete All My Blogs'),$_GET["q"],array('query' => 'delete=myBlogs'));
$variables['profile'] = array('content_profile' => $op);
$variables['user_profile'] = implode($variables['profile']);
}
我的 hook_menu 是
function blogs_additions_menu(){
$items= array();
$items['users/%?delete=myBlogs'] = array(
'page callback' => 'delete_all_blogs',
'access arguments' => array('access blogs additions'),
'type' => MENU_CALLBACK,
);
return $items;
}
还有我的 delete_all_blogs()
function delete_all_blogs(){
global $user;
$sql = "SELECT nid FROM node node WHERE node.uid='".$user->uid."'AND node.type='blog'";
$result = db_query($sql);
while ($row = db_fetch_object($result)) {
//print $sql;
node_delete($row->nid);
}
drupal_set_message('test', 'test');
}
我的用户可以这样查看他们的个人资料 www.mysite.com/users/barack-obama
我的钩子似乎不起作用。网址中使用的 % 可能有错误。我不知道如何通用地使用它才能正常工作。
【问题讨论】:
-
AFAIK, hook_menu 在其声明中不接受/处理查询参数,因此您需要切换到类似的东西,例如'用户/%/博客/删除'。此外,如果您使用“%”通配符,您通常希望通过“页面参数”条目将它们传递给回调函数 - 请查看链接文档了解详细信息。
标签: drupal drupal-6 hook drupal-hooks