Please save me! I installed a new Drupal 6.22 last week. I wrote a really simple example of hook_menu(), but it didn't work totally. I am really confused, hope someone help me please.
This is test.info
; $Id$
name = Test
description = Allows users to test nodes.
core = 6.x
package = Example
This is test.module
/**
* Implementation of hook_menu().
*/
function test_menu() {
$items['admin/test'] = array(
'title' => 'Test disp',
'description' => 'This is first example.',
'page callback' => 'drupal_get_form',
'page arguments' => array('test_disp'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function test_disp(){
$output.='<table><tr><td><p>This is first example.</p></td></tr></table>';
return $output;
}
First of all, Administrator didn't view my menu item (test disp) until I added a new row 'path'=>'admin/test'.
Second, whatever I clicked muen item(test disp) or visited http://localhost/admin/test, it always show the problem.
Page not found
Welcome to the administration section. Here you may control how your site functions.
The requested page could not be found.
I have no idea why it would like that. I'll really appreciate it if you explain the problem for me.
Comments
flushed cache and run cron?
flushed cache and run cron?
Yes
Yes, I did.
Instead of 'page
Instead of
you need
because
test_disp()returns an HTML output (string), not a form array.The problem still happen.
Thanks for your reply. I tried with the way you gave, but the problem sitll happend. Perhaps there are other problems.
As for adding items to admin
As for adding items to admin menu: you can easily add items to existing categories, e.g.,
admin/settings/mytestitemoradmin/build/mytestitem; to create a new category, you'd first need to do something like this:...and then you can go on with adding
admin/mycategory/myitemetc.Hook Menu
Hope it helps.
Abhishek Sawant
Drupal Developer