Search code examples
phpdrupalsearchdrupal-6drupal-theming

How to print out search results in drupal 6


I created a custom searchpage.tpl.php to print out search form and search results using the following code:

<div class="searchblock">
<?php
print drupal_get_form('search_form');
?>
</div>

<div class="search-result <?php print $search_zebra; ?>">
  <dt class="title">
    <a href="<?php print $url; ?>"><?php print $title; ?></a>
  </dt>
  <dd>
    <?php if ($snippet) : ?>
    <p class="search-snippet"><?php print $snippet; ?></p>
    <?php endif; ?>
  </dd>
</div>

It shows the search form correctly and when I search a phrase, URL changes to http://domain.com/search/node/phrase But it doesn't show the search results, How can I make it work please?


Solution

  • Here's the solution:

    <div class="searchblock">
    <?php
    print drupal_get_form('search_form');
    ?>
    </div>
    
    <?php
    $keys = arg(2);
    print search_data($keys, $type = 'node');
    ?>
    </div>