3

I currently have this in template.php to remove the 'username's blog' link from blog entries.

function phptemplate_links($links, $attributes = array()) {
    unset($links['blog_usernames_blog']);
    return theme_links($links, $attributes);
}

How would I go about using unset to remove the 'username's blog' link from the search results page?

1
  • On my site 'username's blog' isn't in search results. - Also I would be wary of any answers recommending you unset or hide the search result info, because that info contains a number of different things and you probably don't want to get rid of it all.
    – rooby
    Apr 22, 2013 at 13:24

4 Answers 4

2

Consider using Display Suite module.

To make changes to search results for article content type, Goto admin/structure/types/manage/article/display and enable the search result custom display.

Then visit admin/structure/types/manage/article/display/search_result and add or remove the fields as per your requirement.

1
  • How are you able to remove the 'username's blog' link from the search results page? Don't see an option to do that in the way you're describing.
    – Rob Orr
    Jan 7, 2016 at 17:48
1

one simple way without any change in template files.. Just add following code in your css.

.search-info {
display: none;
}

It done all the tricks..

Hope this will help you.

0

You can implement using ThemeName_preprocess_search_result() function. Just Refer this link from Drupal.org: http://drupal.org/node/1101554#comment-5345554

/**
    * Process variables for search-result.tpl.php.
    *
    * @see search-result.tpl.php
    */
    function YOUR_THEME_NAME_preprocess_search_result(&$variables) {
      // Remove user name and modification date from search results
      $variables['info'] = '';
    }

Another solution is that you can override the search-result.tpl.php file in your theme folder. Just remove following snippet from the file:

<?php if ($info): ?>
      <p class="search-info"><?php print $info; ?></p>
    <?php endif; ?>
7
  • This broke the drupal site and stopped it loading :/ Oct 3, 2012 at 10:48
  • check the edit of the answer Oct 3, 2012 at 11:07
  • Hey, I had already done this to remove the authors name and publishing date for entries but it doesn't remove the user blog URL Oct 3, 2012 at 11:30
  • so do you want to hide xyz's blog xx reads information form search results ? xyz: user name xx: number of reads and various other attributes Oct 3, 2012 at 11:37
  • I think it is coming $info_split variable, when i did var_dump($info_split) then it showed me lots of attributes. You can unset some of these variables. Just see the comments of search-result.tpl.php Oct 3, 2012 at 12:16
0

You can find search-result.tpl.php file in your drupal instance folder modules/search. You need to edit that file to hide the author and date details.

Place this part of code in HTML comments tag.

<?php if ($info): ?>
      <p class="search-info"><?php print $info; ?></p>
      <?php endif; ?>

Now, reload the page. In that way you can remove author details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.