【问题标题】:Drupal 7 Custom Template Using hook_menu使用 hook_menu 的 Drupal 7 自定义模板
【发布时间】:2014-05-27 12:24:24
【问题描述】:

我正在尝试使用 Drupal 7 中的这些钩子制作自定义页面模板,但是当我在浏览器中打开时它显示空白页面。这是我的代码

/*
    Implements hook_menu();
*/
function story_menu ()
{
    $items['story/filters'] = array(
        'title' => 'Search For stories',
        'page callback' => 'story_filter_page',
        'access arguments' => array('access content'),
    );
    return $items;
}     


// Implements Page Callback
function story_filter_page ()
{

    return theme('story_search_filter_page', array('title' => 'Testing'));
}


/*
    Implements hook_theme();
*/
function story_theme($existing, $type, $theme, $path)
{
    return array(
        'story_search_filter_page' => array(
            'variables' => array('title' => NULL),
            'template' => 'custom-page',
        ),
    );
} 

我已经在我的模块目录中创建了模板文件:custom-page.tpl.php。

【问题讨论】:

  • 这似乎是对的。可以分享一下日志吗?
  • 从哪里可以找到日志?
  • <site_url>/admin/reports/dblog
  • 你清除了菜单缓存对吗?
  • 日志为空。是的,我已经多次清除缓存。还有其他方法可以调试吗?

标签: templates drupal drupal-7 hook-menu hook-theme


【解决方案1】:

我已经弄清楚为什么页面显示为空白。基本上故事是我的内容类型,所以在我的主题中有一个 tpl 文件名: page--story.tpl.php 并且该文件是空的..所以这就是为什么我的页面显示空白屏幕.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多