[support] Including files
Larry Garfield
larry at garfieldtech.com
Wed Jun 25 04:19:49 UTC 2008
The file and file path keys are only needed to load the page callback itself.
You are correct that url() et al should exist long before you get to the page
callback. That suggests something else is wrong.
Also note that in D6, you do *not* need to specify a file key if the callback
is in the .module file. You only need to do so if it is in a different file.
(Mind you, you should be putting your page callback in separate files for
performance reasons.)
Try moving the callback to a mymodule.pages.inc file and updating the menu
item accordingly, or else remove the file key completely and keep the page
callback in the .module file. Remember to refresh your menus by hitting the
clear cache button on the Performance page. See if it works now.
On Tuesday 24 June 2008 7:27:36 am Matt Connolly wrote:
> I'm writing a module to custom drupal for our needs.
>
> My question is about including files.
>
> I have some page callbacks, which are defined in my hook_menu function
> like so:
>
> $items['mymodule/myaction'] = array(
> 'title' => 'Custom Action',
> 'page callback' => 'mymodule_myaction',
> 'type' => MENU_CALLBACK,
> 'file' => 'mymodule.module',
> 'access callback' => TRUE,
> );
>
> However, common functions, such as `url()` cannot be used because they
> are not included.
>
> I would have thought that `/includes/common.inc` would be already
> included, since drupal has got far enough to call my page callback
> function.
>
> In my handler function, I have had to include:
>
> require_once './includes/common.inc';
> require_once './includes/path.inc';
>
> to access drupal's functionality that I want.
>
> Or have I missed something really obvious!!?
>
> -matt
--
Larry Garfield
larry at garfieldtech.com
More information about the support
mailing list