自定义模块将是一个很好的方法,因为它在主题层之前加载,并且可以从 Drupal 中的几乎任何地方访问,除了重量低于自定义模块的其他模块。对于钩子和其他覆盖,它也可能派上用场。
但是,如果您必须在主题层中使用它,另一种选择是将其添加到您的主题的 template.php 中,这应该使其在 page.tpl.php 等中可用,但不是我不相信的块。
/sites/all/modules/mymodule/mymodule.info
name = My Module
package = !
description = It is MY module, not yours!
core = 6.x
包“!” 将使该模块出现在模块页面的顶部
/sites/all/modules/mymodule/mymodule.module
<?php
// Load mymodule.morePHP.inc
module_load_include('inc', 'mymodule', 'mymodule.morePHP');
// A custom function
function mymodule_my_custom_function($args) {
/* do custom stuff here */
return 'output';
}
/sites/all/modules/mymodule/mymodule.morePHP.inc
<?php
// An included custom function
function mymodule_other_custom_stuff() {
}