0

我在 Drupal 7 中设置了一个搜索页面,当我在输入关键字后单击 Search something 时,它只显示一个空的page.tpl.php. 页。换句话说,它只是向我展示了page.tpl.php没有结果的模板。

这对我来说实际上是令人惊讶的。搜索页面不应该显示page.tpl.php模板,但它正在显示该模板。我启用了搜索模块,search-result.tpl.php并且search-results.tpl.php在我的主题文件夹中;但它仍然向我展示page.tpl.php模板。但是,当我删除page.tpl.php时,它可以完美运行。知道为什么会这样吗?——</p>

有没有办法解决它?为什么会这样?我怎样才能创建一个搜索页面模板(如 page--search--results.tpl.php)并且它只是读取它?

非常感谢

页面.tpl.php

<?php
/**
 * @file
 * Theme implementation to display a single Drupal page.
 *
 *
 * @see template_preprocess()
 * @see template_preprocess_page()
 */
?>

<div class="wrapper">
<!--Header-->
  <header>
    <div id="top">


      <?php global $base_url; ?>
      <div id="logo">
        <?php if ($logo): ?>
          <a href="<?php print $front_page; ?>"><img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" /></a>
        <?php else: ?>
          <?php if ($site_name): ?>
            <h1 id="logo-text"><a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>"><?php print $site_name; ?></a></h1>
          <?php endif; ?>
        <?php endif; ?>

      </div>


      <div id="searc"> <img src="<?php echo $base_url."/jkl/".$directory ?>/images/MK.jpg" id="mk" width="227" height="51" border="0" alt="Company Company">
        <form class="lmksearch">
          <input type="search" name="s" value="" class="searchbox">
        </form>
      </div>

    </div>


    <!-- Menu -->
    <div id="menu">
     <?php if ($main_menu): ?>
      <div  class="nav">
        <?php print theme('links__system_main_menu', array(
          'links' => $main_menu,
          'attributes' => array(
            'id' => 'main-menu-links',
            'class' => array('links', 'clearfix'),
          ),
          'heading' => array(
            'text' => t('Main menu'),
            'level' => 'h2',
            'class' => array('element-invisible'),
          ),
        )); ?>
      </div>
      <?php endif; ?>
    </div>


    <!--menu--> 
  </header>
<!--Header END-->

<!--content-->
<div class="c"></div>
<div class="content-wrapper">

  <div class="teaser-content-cat">

    <div class="page-title">Publication: <?php print $node->field_category['und'][0]['taxonomy_term']->name; ?></div>

    <!-- White Canvas on Black Starts here -->
    <div class="content-canvas">

        <div class="article-node left left-side">

          <!-- article would come here -->
          <h3><?php echo $node->title; ?></h3>
          <p class="teaser-content-desc"><?php print $node->field_month['und'][0]['value']; ?> | <?php print $node->field_author_s_['und'][0]['value']; ?> </p>

          <p>
              <div class="content-from-admin">

                <?php if ($search_results) : ?>
                    <?php include "search-result.tpl.php" ; ?>    
                <?php endif; ?>

                <p class="article-subhead"><?php print $node->field_subtitle['und'][0]['value']; ?></p>
                <?php echo $node->body['und'][0]['value']; ?>
              </div>

          </p>


        </div>

        <!-- Side bar --> 
        <div id="viewrow" class="right right-side">

            <?php print render($page['sidebar_first']); ?>

        <!-- Sidebar -->  
        </div>


        <!-- Clearing Both Left and Right Floating Elements. -->
        <div class="c"></div>

        <!-- View Row Ends -->
        </div>

    <!-- White Canvas Ends -->
    </div>

    <!--Footer-->
    <div class="footer">
        <?php print render($page['footer']); ?>
    </div>

  <!-- Teaser Ends -->
  </div>

<!--Wrapper end-->
</div>

</body>
</html>
4

1 回答 1

1

Check the template suggestions for Drupal 7.

If you need to change the whole page template you have to use page--search.tpl.php or page--search--node.tpl.php respectively (if your path is /search/node). Because search-results.tpl.php is the default wrapper for search results inside page not for the page.


Edit after the submitted page.tpl.php code:

You are missing the <?php print render($page['content']); ?> in the page.tpl.php file! Please follow the Drupal Theming documentation guide.

于 2013-08-09T19:54:25.520 回答