要創建未鏈接到節點的頁面,您必須在自制模塊中實現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過濾器模塊。