[support] How do you stop info on search result?

Jason Flatt drupal at oadaeh.net
Sat May 26 18:44:12 UTC 2007


On Saturday 26 May 2007 11:09:04 A-NO-NE Music wrote:
> I am happy to report I was able to override the function by writing
> phptemplate_search_item() in the template.php.  However, I must wonder
> what I did was OK since it isn't the same as what the documentation tells
> me.
>
> <http://drupal.org/node/11811>
> This tells me I need _phptemplate_callback() but I couldn't figure out
> what the param should be.  The example is too different, and the API
> list doesn't mention this in detail.  I tried a few params by guesses,
> all which returned in PHP error.

In your theme's main directory (themes/garland/, if that's what you're using, 
though I'd create a duplicate, rename it and modify the duplicate) create a 
template.php file containing the following code (or add the code to an 
already existing file, minus the opening <?php line):

<?php
function phptemplate_search_item($item, $type) {
  //  The following should be all on one line:
  return _phptemplate_callback('search_item', array('item' => $item, 'type' => 
$type));
}

(Note: no closing ?> is necessary.)

Then create a file called search_item.tpl.php in the same directory with the 
code you want used for your theming. You can use one of your 
existing .tpl.php files (page.tpl.php, node.tlp.php, etc.) as an example for 
how to format your search_item.tpl.php file, but copy the code from the 
search module function you're overridding as a starting point.

Though I haven't completed it yet, I was doing yesterday what you're doing 
today with that and the theme_search_page functions. As an example for you, 
here's what I have so far in my search_item.tpl.php:

<dt class="title">
  <a href="<?php echo check_url($item['link']); ?>"><?php echo 
check_plain($item['title']); ?></a>
</dt>

<?php
  $info = array();
  if ($item['type']) {
    $info[] = $item['type'];
  }
  if ($item['user']) {
    $info[] = $item['user'];
  }
  if ($item['date']) {
    $info[] = format_date($item['date'], 'small');
  }
  if (is_array($item['extra'])) {
    $info = array_merge($info, $item['extra']);
  }
?>

<dd>
  <?php echo ($item['snippet'] ? '<p>'. $item['snippet'] . '</p>' : ''); ?>
  <p class="search-info">
    <?php echo (implode(' - ', $info)); ?>
  </p>
</dd>


My goals for my customization are different than yours. For you, I would 
remove or comment out the part that looks like this:
  <p class="search-info">
    <?php echo (implode(' - ', $info)); ?>
  </p>

(And you might as well remove all that code which fills in that $info 
variable.)


-- 
Jason Flatt
http://www.oadaeh.net/
Father of Six:  http://www.flattfamily.com/ (Joseph, 14; Cramer, 12; Travis, 
10; Angela; Harry, 7; and William, 12:04 am, 12-29-2005)
Linux User:     http://www.xubuntu.org/
Drupal Fanatic: http://drupal.org/


More information about the support mailing list