Drupal 6 page-customnamehere.tpl.php如何工作
我正在使用drupal 6.26安装。我可以在我使用的主题目录中看到文件名,如Drupal 6 page-customnamehere.tpl.php如何工作,drupal,drupal-6,Drupal,Drupal 6,我正在使用drupal 6.26安装。我可以在我使用的主题目录中看到文件名,如page-2011-custom-landing-page.tpl.php 据我所知,我应该能够在http://www.mydomain.com/2011-custom-landing-page然而,我只是在那个地址收到一条“找不到页面”的消息。发生什么事了 如果在主题文件夹中看到文件名为“page-2011-custom-landing-page.tpl.php”,则表示有一个名为“page-2011-custom-
page-2011-custom-landing-page.tpl.php
据我所知,我应该能够在http://www.mydomain.com/2011-custom-landing-page
然而,我只是在那个地址收到一条“找不到页面”的消息。发生什么事了
如果在主题文件夹中看到文件名为“page-2011-custom-landing-page.tpl.php”,则表示有一个名为“page-2011-custom-landing-page.tpl.php”的模板文件用于页面。该页面可以在一个自定义模块中定义
像这样:
<?php
/**
* Implements hook_menu().
*/
function custommodulename_menu() {
$items['pathname'] = array(
'title' => 'title',
'page callback' => 'custommodulename_pagename',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_theme().
* Adds our theme specificiations to the Theme Registry.
*/
function custommodulename_theme($existing, $type, $theme, $path) {
$items = array();
$items['custommodulename_pagename_page'] = array(
'render element' => 'form',
'template' => 'page-2011-custom-landing-page', //name of file(template) to be created,here create page-2011-custom-landing-page.tpl.php in the custom module folder
);
return $items;
}
/**
* Callback function(menu)
*/
function custommodulename_pagename(){
return theme('custommodulename_pagename_page');
}
?>
page-2011-custom-landing-page不是url,而是模板名。您可以看到使用该模板访问菜单回调的模板my中的内容。(在这里:)
参考资料: