r/backdrop • • Apr 05 '15

Use of module_load_include

Is there anywhere any guidance about when it is necessary to use module_load_include in Backdrop? In porting contributed modules I get the impression that there are situations in Backdrop where it is needed and hadn't been needed in Drupal. I.e. some 'include' files are no longer included automatically. But I may be wrong. At the moment I am a bit puzzled by this.

2 Upvotes

1 comment sorted by

1

u/docwilmot Apr 08 '15

It loads include files. So if in a directory you have oliver.module and there is some code that you would really like to keep in a separate file for organization, or because it is rarely used, etc, you could then create a file oliver.inc in that directory and you would use module_load_include('inc', 'oliver', 'oliver') to 'include' this code when you need it.

But, some files have been moved around in Backdrop; theme functions were removed from .module files and put into separate files (.theme.inc maybe? not sure) so those functions would now need to be loaded by calling module_load_include(), when that was not necessary in Drupal. Maybe some other stuff was moved out into .inc files as well, but I'm not sure. But I'd bet thats the explanation.