How to include file(s) to .module?
sisyphus - November 21, 2008 - 00:39
i would like to break the .module file into several .inc files. how to include them into .module using drupal built-in function?
thanks a lot.
i would like to break the .module file into several .inc files. how to include them into .module using drupal built-in function?
thanks a lot.
A couple of examples
You can specify an external file for your theme functions or preprocess functions:
http://api.drupal.org/api/function/hook_theme/6
Page handlers can be defined in an external file (eg for admin functionality you only want loaded when needed):
http://drupal.org/node/146172
Other hooks may also have ways of including files...
--
Anton
thank you. but i meant is
thank you.
but i meant is there any drupal functions similar to require_once() of php or i can use require_once() direct?
thanks.
You should be able to use it directly without any problem
Keep in mind that you might need to use a path relative to index.php rather than your module file. There are Drupal functions to give you the paths for modules and theme so you don't have to hard code the path.
I would recommend taking another look at the methods I listed above though. They are more "Drupal native" and can take advantage of future optimisations (eg D7 will have a comprehensive registry) etc. A require_once() will run on every page load, whereas the Drupal registries are designed to only load files when needed.
--
Anton
You could try the
You could try the include_once() function. That is what we use typically. You can use any php function with Drupal...
Regards, Derek
http://collectivecolors.com
module_load_include
Hi, I think you're looking for http://api.drupal.org/api/function/module_load_include/6
http://www.davyvandenbremt.be
http://www.drupalcoder.com
Yeah that would be a good
Yeah that would be a good way too!
Derek