Moshe Shaham
Moshe Shaham

Reputation: 15984

drupal 6: adding a page for administrators

I need to do something and I just can't figure out what's the best option to do that.

In drupal, I need to add a page that displays information with a simple php script, and it should display it only to administrators.

I thought about adding a menu item like this:

$items['admin/visits_log'] = array(
        'page callback' => 'visitst_log',
        'access callback' => true,
        'access arguments' => TRUE,
        'type' => MENU_CALLBACK,
      ); 

but it's not showing with a page, just text...

I know it's a simple question, but I just need a little direction..

Upvotes: 0

Views: 62

Answers (2)

Yi Yang
Yi Yang

Reputation: 13

Note that if you want to make the page only visible for admin users, you need to have access setup properly instead of just "true". For example:

$items['admin/visits_log'] = array(
        'page callback' => 'visitst_log',
        'access arguments' => array('administer nodes'),
        'type' => MENU_CALLBACK,
      ); 

(if you don't specify access callback it will use user_access() by default

Upvotes: 0

trunks
trunks

Reputation: 36

You must return $output as HTML code (instead of print & exit), to be rendered by drupal theme system. That callback can be coded like this:

function visitst_log() {
  $output = "<p>Hello world!</p>";
  return $output;
}

Upvotes: 2

Related Questions