The .info file and other files

3 replies [Last post]
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11


I'm writing a module in Drupal 7 with both classes and functions. I want to split these over several files and call one function from another file. I notice that some files need to be declared in the .info file and others not. I'm having problems with 'seeing' functions whose definition resides in other files when called from another file.

What are the rules here? Can someone point me in the direction of some good documentation?

Thanks in advance.


Last seen: 6 years 29 weeks ago
Joined: 2011-06-11
It gets a little confused

Actually, one thing I have noticed is that if you edit the .info file without disabling and uninstalling the module, the Drupal installation itself becomes confused - understandably so. Having deleted the database followed by a complete re-install, it started to behave itself much better.

Last seen: 6 years 29 weeks ago
Joined: 2011-06-11
Further info

If anyone else is wondering about this, I found a good post on the buildamodule blog:
The correct way to include files in your drupal module

However, I do have one remaining question. Is there a way to run module_load_include() once only in each file? I seem to have to call it in each function that may need it.

I'm feeling a little lonely here. Is all this obvious to everyone or are massive code files in fashion now?



Chris Shattuck
Last seen: 9 weeks 5 days ago
Joined: 2009-08-16
Hello Martin, Here are some

Hello Martin,

Here are some thoughts on your questions:

  • You should add any file that includes function definitions in your .info file. After you edit the .info file, you will need to clear your caches in order to register the new data in the info file.
  • You should be able to run module_load_include() in a hook_init() function if you want to load it on every page.

Let me know if this works for you!


Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:

Contact us

Below are the supported keyboard shortcuts for our video player.

Start / stop video
Go to next video
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
Jump to a percentage (2 is 20%, for example)
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
1 month
6 months
10% off
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.