要创建未链接到节点的页面,您必须在自制模块中实现hook_menu。
function MODULENAME_menu() {
return array("stuff" => array(// link (in your case: http://mypage.com/stuff)
'title' => "stuff", // title of the page
'page callback' => "themefunction", // logic for the content
'type' => MENU_CALLBACK // there are more types, read hoo_menu() for further details
);
}
可以替代themefunction有你喜欢的任何东西,但你必须实现它!
function themefunction() {
// do some theming output stuff like:
$items['hello'] = "Hello World!"; // your variable output
return theme('stuff_theme', array('items' => $items)); // say Drupal to theme that stuff in your default page-template
}
然后,你需要通过实施hook_theme登记在Drupal的主题(这也是在你的主模块文件DON)
function MODULENAME_menu() {
return array(
'stuff_theme' => array(// file name of the template WITHOUT .tpl.php
'variables' => array(
'items' => NULL // variables that are assigned to the template
)
)
);
}
最后,您需要创建模板* stuff_theme.tpl.php *(在模块文件夹中):
<div><?= $items['hello']; ?></div>
不幸的是,这是创建真正自定义内容页的唯一方法。对于小型代码注入节点,您还可以启用PHP过滤器模块。