0

我正在使用 drupal 6.26 安装。page-2011-custom-landing-page.tpl.php我可以在我正在使用的主题目录 中看到文件名。

据我了解,我应该能够看到这个模板,http://www.mydomain.com/2011-custom-landing-page但是我只是在那个地址收到“找不到页面”的消息。这是怎么回事?

4

1 回答 1

0

如果您在主题文件夹中看到文件名为“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,它是模板名称。您可以在访问使用该模板的菜单回调时看到模板内的内容。(这里是:http: //yoursite.com/pathname

参考: http: //www.developerdoc.com/answer/add-template-menu-call-back

于 2013-09-19T10:58:55.277 回答