Frage

I writing custom module for Drupal 7 and got the following warning:
Warning: Invalid argument supplied for foreach() в функции menu_unserialize() (строка 400 в файле /var/www/auth/includes/menu.inc).

My hook_menu is here:

function mnogomirauth2_menu() { $menu['tables/udkservers'] = array( 'title' => 'udkserversTable', 'page callback' => '_menu_test', 'access arguments' => TRUE, 'type' => MENU_NORMAL_ITEM ); return $menu; } function _menu_test() { echo "test"; }

Please, tell me, what's wrong with this code?

Best regards.

War es hilfreich?

Lösung

According to Drupal API for hook_menu

"access arguments": An array of arguments to pass to the access callback function, with path component substitution as described above. If the access callback is inherited (see above), the access arguments will be inherited with it, unless overridden in the child menu item.

It seems that you have specified wrong argument TRUE for access arguments.

Andere Tipps

The below mentioned code will solve it:

Before:

'access arguments' => TRUE,

After:

'access arguments' => array('Your Permission'), //array(TRUE)

The code that work is the following one.

function mnogomirauth2_menu() {
  $menu['tables/udkservers'] = array(
    'title' => 'udkserversTable', 
    'page callback' => '_menu_test', 
    'access callback' => TRUE, 
    'type' => MENU_NORMAL_ITEM
  );

  return $menu;
}

It's the access callback that can be a number. If it evaluates to TRUE, every user has access to the menu item; it it evaluates to FALSE, no user has access to the menu item.

References

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top