What Nikit said is correct.
I will add there are some hooks that are allowed to define which files need to be loaded. Examples of such hooks are hook_theme()
, and hook_menu()
.
A module should never unconditionally load a file it needs calling module_load_include()
from outside a function.
function book_menu() {
$items['admin/content/book'] = array(
'title' => 'Books',
'description' => "Manage your site's book outlines.",
'page callback' => 'book_admin_overview',
'access arguments' => array('administer book outlines'),
'file' => 'book.admin.inc',
);
$items['admin/content/book/list'] = array(
'title' => 'List',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/content/book/settings'] = array(
'title' => 'Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('book_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 8,
'file' => 'book.admin.inc',
);
// …
}
function user_theme() {
return array(
'user_picture' => array(
'arguments' => array('account' => NULL),
'template' => 'user-picture',
),
'user_profile' => array(
'arguments' => array('account' => NULL),
'template' => 'user-profile',
'file' => 'user.pages.inc',
),
// …
'user_admin_perm' => array(
'arguments' => array('form' => NULL),
'file' => 'user.admin.inc',
),
// …
);
}
comment_total_count()
,comment_today_count()
is used in templates,comment_thread()
is required on admin page as well as on content page.comment_insert()
on content page whilecomment_remove()
andcomment_edit()
on admin page. Do I need to use conventionalrequire
orinclude
syntax? And what about to include multiple files? – Daric