Hi,

I'm try to customize my search results page, specifically the part that shows the results.

<div class="box">

I need some way to target this box from my CSS, the problem is, this same class is used on other pages. If I could toss a class in the body tag, or simply rename this class, it would be great.

Anyone h ave any ideas or examples?

Comments

nimazuk’s picture

hi,
You can add this code to your theme's Template.php file. class="myClass" is your target.
Actually this theme function overrides the search result function in search.module.

<?php
function phptemplate_search_item($item, $type) {
  $output = ' <div class="myClass"><dt class="title"><a href="'. check_url($item['link']) .'">'. check_plain($item['title']) .'</a></dt>';
  $info = array();
  if ($item['type']) {
    $info[] = check_plain($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']);
  }
  $output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd></div>';
  return $output;
}
?>

N.Mehrabany
CSS Formatter & Optimizer
Baruzh web design & programming

Nima

Kirk’s picture

Thanks, but it's not exactly what I'm looking for... Currently, search results return the following html The part I am trying to modify is the parent div... The class="box" one. That class appears on several pages, and I need to have it look different on the search result than it does on the other pages.

FYI: This class="box", on other pages, typically contains the comment form. It seems odd to me that 2 items with such a distinctly different purpose would share the same CSS classes.

<div class="box">
	<h2 class="title">Search results</h2>
		<div class="content">
				<dl class="search-results">
				<dt class="title"><a href="#">Test</a></dt> 
				<dd><p class="search-info"></p></dd>
			</dl>
		</div>
</div>