开发者

Acces/See settings page for a custom odule

I upgraded a module from 5 to 6. I only have one problem: I can access the settings page for it, but can not see the contents of it. This is my code:

function agbnagscreen_menu() {
  global $user;
  $items = array();

    if (agbnagscreen_nag($user)) {
//       var_dump($_GET['q']); die();
      drupal_goto(sprintf('%s/%s', AGBNAGSCREEN_NAGURL, base64_encode($_GET['q'])));
      die();
    }

    $items['admin/settings/agbnagscreen'] = array(
开发者_如何学Go     // 'path' => 'admin/settings/agbnagscreen',
      'title' => 'AGB nagscreen',
      'access callback' => user_access('Einstellungen von AGB aendern'), 
      //'access' => user_access('Einstellungen von AGB aendern'),
      'page callback' => 'drupal_get_form',
      'callback arguments' => array('agbnagscreen_settings_fapi'),
    );

    $items[AGBNAGSCREEN_NAGURL] = array(
     // 'path' => AGBNAGSCREEN_NAGURL,
      'title' => 'Allgemeine Geschaeftsbedingungen',
      'access' => TRUE,
      'callback' => 'drupal_get_form',
      'callback arguments' => array('agbnagscreen_fapi'),
      'type' => MENU_SUGGESTED_ITEM,
    );

  return $items;
}

I think the problem is cause by this line:

'page callback' => 'drupal_get_form',

Is that correct? How can I write it, that it works?


You might want to read through the Drupal menu system (Drupal 6.x) handbook page to understand the changes to the menu system: you have several problems in your hook_menu implementation.

  1. The conditional at the top will never fire: Drupal 6 only calls hook_menu() when the menu is rebuilt, not on every page load.
  2. There is no callback: use page callback.
  3. The page callback accepts page arguments, not callback arguments.
  4. There is access: use access callback.
  5. access callback always a string containing the function name, not a function, and defaults to "user_access": you need to supply access arguments.

A modified version of your hook_menu implementation might be:

function agbnagscreen_menu() {
  $items = array();

  $items['admin/settings/agbnagscreen'] = array(
    'title' => 'AGB nagscreen',
    'access arguments' => array('Einstellungen von AGB aendern'), 
    'page callback' => 'drupal_get_form',
    'page arguments' => array('agbnagscreen_settings_fapi'),
  );

  $items[AGBNAGSCREEN_NAGURL] = array(
    'title' => 'Allgemeine Geschaeftsbedingungen',
    'access arguments' => array('access content'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('agbnagscreen_fapi'),
    'type' => MENU_SUGGESTED_ITEM,
  );

  return $items;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜