[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
我的钩子似乎不起作用。url 中使用的 % 可能有错误。我不知道如何通用地使用它才能正常工作。