0

在模块用户中:

  $items['user/%user/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_profile_form', 1),
    'access callback' => 'user_edit_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'file' => 'user.pages.inc',
  );

在我的模块中:

function MYMODULE_menu_alter(&$items) {
   $items['user/%user/edit']['access callback'] = 'MYMODULE_can_edit_user';
   $items['user/%user/edit']['access arguments'] = array(1);
   $items['user/%user/edit']['page callback'] = 'MYMODULE_user_edit_page';
}


function MYMODULE_user_edit_page($account){
   if(my_condition){go to page... }
   else { use callback from module User }
}

如果函数 *MYMODULE_user_edit_page* 中的 my_condition 不为 TRUE,如何使用模块用户的默认页面回调?

4

1 回答 1

0

关于什么...

function MYMODULE_menu_alter(&$items) {
  $items['user/%user/edit']['access callback'] = 'MYMODULE_can_edit_user';
  $items['user/%user/edit']['access arguments'] = array(1);

  $current_callback = $items['user/%user/edit']['page callback'];

  $items['user/%user/edit']['page callback'] = 'MYMODULE_user_edit_page';
  $items['user/%user/edit']['page arguments'][] = $current_callback;
}


function MYMODULE_user_edit_page($existing_callback = NULL){
   if(my_condition){go to page... }
   elseif (!empty($existing_callback)) {
     $existing_callback($account);
   }
}
于 2013-06-19T09:57:35.140 回答