I am writing a new module called mynode.module for learning the drupal system. The trouble is that I cant get the http://mysite.com/?q=mynode to get to generate what I want. I get a "Page Not Found".
My mynode_menu is as follows:
/**
* Implementation of hook_menu().
*/
function mynode_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'node/add/mynode', 'title' => t('New node type'),
'access' => mynode_access('create', NULL));
$items[] = array('path' => 'mynode', 'title' => t('New node type entries'),
'callback' => 'mynode_page',
'access' => TRUE, /* Allow access for anybody */
'type' => MENU_CALLBACK);
}
return $items;
}
I have coded mynode_page similar to blog_page_last() in the blog.module(basically, it generates last few posts of 'mynode' type). Still when I go to http://mysite.com/?q=mynode to get to generate what I want. I get a "Page Not Found" error.
What could be the reason that ?q=mynode is not recognized? Am I doing anything wrong in the hook_menu? How can I debug this?
Little bit background into what I did:
I started from page.module & changed it for mynode.module. In the process i created mynode_form, mynode_validate, mynode_insert, mynode_load, mynode_view as per documentation at 4.6 node_example.module
Now I am able to do node/add/mynode and view the posts & categories at ?q=taxonomy/term/num.
Thanks for any help
Comments
clear cache
Possibly, you tried a variation of your current code first, and then changed something when it didn't work. In that case, you should first clear your cache table, since the menu callback is in the $may_cache part of hook_menu.
Thanks a lot
Thanks a lot Dries!! what you described was exactly the problem.
It works now..
Drupal is amazing!!
How do you clear the cache table?
How do you clear the cache table? I'm using phpmyadmin. Do I need it? Thanks. :)
Run this query
Be sure to add your table prefix if you use one. Mine is drupal_cache.
It'd be nice to have a link in the adminstration section to do this. Of course it wouldn't be very hard to add it, I just haven't done so yet.
empty
In phpmyadmin, click the cache table, then click the "empty" tab (don't click "drop").
Thanks guys! Same process?
Thanks guys! Is the query given by benshell the same as the emptying process posted by DriesK? Most probably will use the empty tab.
truncate
if you click 'empty' in phpmyadmin, the query that is executed is "TRUNCATE TABLE 'cache'". The result is the same as deleting all rows, but how MySQL actually performs the operation may be different. However, this is not relevant when emptying Drupal's cache table :-)
Also having module problems...
I've been playing around writing a module which semi-integrates Squirrelmail into Drupal (don't get excited, it's honestly nothing special - literally just an onsite log on page which takes you straight into your Squirrelmail installation and an addressbook manager - global and users)... Anyways, so far it's been going okay... I'm getting on with it and everything worked fine, I've finished the redirect log on and the global addressbook manager but now all of a sudden in the settings page neither of the buttons at the bottom of the screen work...? (Save config, Reset) They 'used' to work because I tested them and I haven't altered the settings part of my code at all:
I did however mess about with the permissions part, but as far as I can tell it looks okay now?
Anyways, I emptied the cache hoping it'd be something simple like that, but nope... There's something wrong and I think I need a fresh pair of eyes to tell me what I'm overlooking. I'm sure I'm just being an idiot somewhere!
Thanks
Pobster
Thanks, DriesK! Did use the
Thanks, DriesK! Did use the empty tab -- this problem was the main hurdle to developing my Flexilist module -- http://drupal.org/node/34993 -- and it was smooth sailing after I figured out what was wrong. :)