You need to login to send post. No account yet? Create one:
Create account

Hide the author of node and date in Drupal search

2 replies [Last post]
Pete

I feel that sometimes is Drupal too complex - there is a lots of informations which I want to disable, but there is no such option. Is possible to switch of name of author of node and date of creation in Drupal search result. Thanks you in advance, but I am more designer than coder...

admin
You are right... Drupal isn't good in "hide something" :-)

In this case should webdesigne use Drupal hook function. All is done in your template.php file in theme folder, but you have to copy into folder of your theme file 'search-result.tpl.php' from search module folder too. This PHP snippet is from http://koobmeej.blogspot.com/2008/10/theme-drupal-search-results.html and implementation is for ZEN theme in Drupal 6.

  • Add to section 'Implementation of HOOK_theme()' this code:

$hooks['search_result'] = array(
  'arguments' => array('result' => NULL, 'type' => NULL),
  'template' => 'search-result',
  'path' => drupal_get_path('module', 'search')
);

  • And at the end of template.php file add:

function phptemplate_preprocess_search_result(&$variables) {
    $result = $variables['result'];
    $variables['url'] = check_url($result['link']);
    $variables['title'] = check_plain($result['title']);

    $info = array();

    /* HIDE THIS FROM END USER
    if (!empty($result['type'])) {
       $info['type'] = check_plain($result['type']);
    }
    if (!empty($result['user'])) {
       $info['user'] = $result['user'];
    }
    if (!empty($result['date'])) {
       $info['date'] = format_date($result['date'], 'small');
    }
    if (isset($result['extra']) && is_array($result['extra'])) {
       $info = array_merge($info, $result['extra']);
    }
    */

    $variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : '';
    $variables['info_split'] = $info;
    $variables['info'] = implode(' - ', $info);
    $variables['template_files'][] = 'search-result-'. $variables['type'];
}

  • Don't forget copy search-result.tpl.php into your theme folder.
  • Don't forget rebuild theme registry.
mvalverde
... the simplest way for me

... the simplest way for me was to copy the search-result.tpl.php from modules/search to my theme path (consider replacing hyphens by underscores) and to simply remove the line printing the $info.

dont forget to rebuild the theme registry ;)

mvalverde (www.explido-software.de)