我遇到了一些我搞不懂的小问题。我有一个网站,并将有一组网页,这将是定制的(但与模板的网页),只是定制内容。
例如:http://mypage.com/?q=stuff
我读到了关于挂钩并创建文件页--stuff.tpl.php和复制的page.tpl.php,但是页面标题没有找到,而且我没有做好,因为复制了page.tpl.php
这些页面将包括自定义手写模块和自定义PHP代码,但总体布局将与其他节点相同。
我怎么能这么做?
发布于 2013-12-09 15:44:31
若要创建未链接到节点的页面,必须在自制模块中实现菜单。
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
);
}
你可以用任何你喜欢的东西来代替它们,但是你必须实现它!
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
}
然后,您需要通过实现主题 (也就是在主模块文件中的don )在Drupal中注册主题。
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 模块。
https://stackoverflow.com/questions/20473300
复制相似问题