This may be obvious to experienced devs, but I'd like to develop a module that appear in drupal as a page. It will definitely not be a content type where users, or even admins would want to add text. There's a whole lot going on in the background, (php code) but the user has only a couple of options and then clicks on a button to do the task.

I've been doing it as a page inside drupal, but PHP in a text box is getting unmanageable in a hurry.

I've looked at the hooks for page, but it doesn't look like they are set up like forms hooks. I also looked at contact_forms module, but I don't know enough about Drupal to understand why it works.

Am I thinking about this the wrong way?

Any advice is welcome.

Comments

nevets’s picture

You probably want to create a module

mpapet’s picture

Following the page_example_baz I did the following. I got the module to appear and the permissions are there and I can click them and the Help items appear. However, nothing in the menu.

function grumbler_help ($path, $arg) {
$grum_help = '';
switch ($path) {
case "admin/help#grumbler":
$grum_help = '

' . t("GUIs for group server. This module's children are all of the GUIs"). '

';
break;

case 'admin/modules#grumbler' :
$grum_help = t("GUIs for group server.");
break;
}
return $grum_help;
} //closes function grumbler_help

function grumbler_perm() {
return array ('administer server', 'create server session', 'use server session');
}

function page_grumbler_baz() {
return t('This is where you, the Group Manager, starts a group session');

}

function page_grumbler_menu() {
$items = array(
'title' => 'grumbler',
'access arguments' => array('create server session', 'administer server'),
'type' => MENU_CALLBACK,
'page callback' => 'page_grumbler_baz',
);

return $items;
} //ends menu

nevets’s picture

You followed an example for Drupal 5. For Drupal 6 see Creating modules, for hook_menu() see "Letting Drupal know about the new function" (a sub-section of "Creating modules").

mpapet’s picture

nevets’s picture

That link also works, though you posted code seems to follow a Drupal 5 example, while the link you posted is clearly Drupal 6.

mpapet’s picture

Thanks for your help on this.

I deleted everything and started over with the latest release, dropped the database and created a new one. Still, doesn't work.

function grumbler_help ($path, $arg) {
  $grum_help = '';
  switch ($path) {
        case "admin/help#grumbler":
        $grum_help = '<p>' . t("GUIs for server.  This module's children are all of the GUIs"). '<p>';
        break;

         case 'admin/modules#grumbler' :
        $grum_help = t("GUIs for server.");
        break;
        }
  return $grum_help;
} //closes function grumbler_help

function grumbler_perm() {
        return array ('administer murmur', 'create server session', 'use server session');
}


function page_grumbler_foo {
        return '<p>'. t('The quick brown fox jumps over the lazy dog.') .'</p>';

} // closes page function

function page_grumbler_menu {
        $items['grumbler'] = array (
        'title' => 'Register to Use the Server,
        'page callback' => 'page_grumbler_foo',
        'access arguments' => array('administer server', 'create server session'),
);
nevets’s picture

Does the menu item show up, if not clear the menu cache.

Otherwise it might be because the default access callback is user_access() and you can only pass it on permission (not even sure 'administer server' is a valid permission).