Posted by mcstrother on March 13, 2010 at 1:29am
Hi.
I've looked all over for this, but have had no luck.
I'm developing at shift-scheduler module, and I would like to add a link to its configuration page to the "Site configuration" menu. Adding the code below to hook_menu() puts a "Edit Slots" link under "Shift Scheduler" when I go to "Administer by Module", but nothing else. I've doubled checked that everything is spelled correctly and all the callbacks are valid.
Any help is very much appreciated.
Thanks!
<?php
$items['admin/settings/shift_scheduler']= array(
'title' => t('Shift Scheduler'),
'description' => t('Administer the slots and default shifts on the shift schedule.'),
'access arguments' => array(
'administer shift_scheduler',
'administer site configuration'
),
'type' => MENU_NORMAL_ITEM,
'page callback' => 'shift_scheduler_admin_slots',
);
$items['admin/settings/shift_scheduler/slot'] = array(
'title' => t('Edit slots'),
'page callback' => 'shift_scheduler_admin_slots',
'access arguments' => array(
'administer shift_scheduler',
),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/shift_scheduler/configure'] = array(
'title' => t('Configure Shift Scheduler'),
'page callback' => 'shift_scheduler_configure',
'access arguments' => array(
'administer shift_scheduler',
),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/shift_scheduler/default_shifts']= array(
'title' => t('Edit default shifts'),
'page callback' => 'shift_scheduler_admin_default_shifts',
'access arguments' => array(
'administer shift_scheduler',
),
'type' => MENU_CALLBACK,
);
return $items;
?>
Comments
_
You haven't double-checked - there's 'arguemnts' in there for a start!
Not to mention the 'MENU_CALLBACk'
See http://drupal.org/node/206764 for more information on using hook_menu.
Pete.
http://adaptive.co.uk
thanks for catching that but it still doesn'twork
Thanks for catching those. That's certainly embarrassing. Though just because I missed a couple doesn't mean I didn't double check...
Thanks for the link too, but I looked at that already
Before posting, I also ran another test in which I copy-pasted the definition for the only menu item that seems to be working and changed it a little (see below) to see if I could get a second menu item to appear in the "Administer by Module" page. If both are left in, only "Edit slots" appears under that area. If the first item is commented out, only 'Edit slots2' appears in that area. In neither case does anything appear under the site configuration menu.
Thanks again for your help,
-mcs
$items['admin/settings/shift_scheduler/slot'] = array('title' => t('Edit slots'),
'page callback' => 'shift_scheduler_admin_slots',
'access arguments' => array('administer shift_scheduler'),
'type' => MENU_NORMAL_ITEM
);
$items['admin/settings/shift_scheduler/configure'] = array(
'title' => t('Edit slots2'),
'page callback' => 'shift_scheduler_admin_slots',
'access arguments' => array('administer shift_scheduler'),
'type' => MENU_NORMAL_ITEM
);
and now it works for some reason...
It seems to be working now (at least in creating links for "Administer by module") though I didn't make any changes to the code. I even tried clearing the cache and uninstalling/reinstalling the module before to no avail. Still no luck with getting links to appear under Site configuration, however.
_
Menus are cached in cache_menu; that may have something to do with it...
Pete.
http://adaptive.co.uk
Well, try this and if it
Well, try this and if it works try not to kick yourself too hard.
Put the trailing "comma" on the last elements in your arrays. I.E.
'type' => MENU_LOCAL_TASK,);
I think I've have experience before where it the trailing comma isn't there, just just doesn't work right.
fast women, pretty cars, sexy computers
Still no luck
Is there any chance it could have something to do with the underscore in the module's name?
Sorry to revive a very old thread. Having the admin links hidden in the "By Module" administration page was a "good enough" solution for a while.
Maybe if you posted the code
Maybe if you posted the code in a format that was actually readable, you would get more help. Right now it's a mess to read.
Full-time freelancer, always looking for work.
jaypan.com (my portfolio)
Sorry
Emacs's default php mode does not conform to the drupal standards. I've fixed the indentation (mostly) and added the php tags for highlighting.
I fixed it
Removing 'administer site configuration' from the access arguments array for $items['admin/settings/shift_scheduler'] fixed the issue. It also got rid of several errors that I thought were unrelated:
* warning: array_fill() [function.array-fill]: Number of elements must be positive in D:\DEVELOPMENT\xampp\www\mysite.tld\includes\database.inc on line 253.
* warning: implode() [function.implode]: Invalid arguments passed in D:\DEVELOPMENT\xampp\www\mysite.tld\includes\database.inc on line 253.
* warning: array_keys() [function.array-keys]: The first argument should be an array in D:\DEVELOPMENT\xampp\www\mysite.tld\modules\user\user.module on line 513.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in D:\DEVELOPMENT\xampp\www\mysite.tld\modules\user\user.module on line 513.
Full description here .