Posted by doomed on May 27, 2009 at 2:45am
Hello, i would like to make small changes to my Search Results Page.
I know i can copy search-result.tpl.php from Drupal's search module folder to the custom Theme folder and edit it there.
In my case i want to remove the user information but keep date/time.
By removing the following line, all of that info is gone:
<?php
print $info;
?>So how do i take the poster's username out but keep the date?
Comments
There is a variable that
There is a variable that contains all the result item data as an array: the $result variable.
In the search_result.tpl.php file of your theme, use the following:
<?phpprint format_date($result['date'], 'small');
?>
$result['type'] and $result['user'] will contain the Content Type and the Node Author name, respectively.
See template_preprocess_search_result reference for further information
Helpful.. Thanks!
Helpful.. Thanks!
Thanks it works!
Thanks this is what i was looking for and is very easy to implement, also you can use the $info_split variable in the search-result.tpl.php file to show the different options
I have used this
<?phpprint $info_split['date'];
?>
but i only got to work when used in the search module not in the theme
drupal 6.14
search 6.14
foliage theme
Please explain
Hi,
Can anybody explain how I can customize the look & feel of the search page? I have copied search-result.tpl.php page from search module to my theme folder. But still it is calling search-result.tpl.php page from search module.
Please expplain the whole process for this. I have not created any function in template.php page. Is it required? If so that how?
Thanks
Hiral Vyas
what to do!
Hi I have made the changes in the module not in the theme because there this was not work for me, also I have found a theme that has that properties and can be configured to hide some things the theme is 0 point maybe can be useful for you.
in this search module file-> search-result.tpl.php, there are some comments that explain some variables that can be used to customize the search! This is my code for search-result.tpl.php:
<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; ?>
<?php if ($info) : ?>
<p class="search-info"><?php print $info_split['date']; ?></p>
<?php endif; ?>
</dd>
Flush that cache
If your place the modified search-result.tpl.php page in your active template, you will see the change once you flush your caches, or at least rebuild your site registry. Recommend you use the Administration Menu module, which is helpful with flushing all caches during development.
Hide it away with CSS
I have hidden it away adding the following to the locale.css
.search-info a {
display:none;
}