开发者

Drupal - Hide a single page from search index

开发者 https://www.devze.com 2023-01-01 17:56 出处:网络
I\'ve taken over an existing Drupal installation and have been asked to remove a single page from the site search results. I know about the lullabot tutorial through this question: Hide Drupal nodes f

I've taken over an existing Drupal installation and have been asked to remove a single page from the site search results. I know about the lullabot tutorial through this question: Hide Drupal nodes from search, but th开发者_JAVA百科at talks about excluding a class of content when I really just want to exclude a single page.

I've tried manually deleting the node from the search_index table, but that didn't seem to work either.

Any recommendations for excluding a single regular content page from the search index?


I've just had to work out something similar (hiding particular cck fields from the search index on a node by node basis) - took some tracking down, but this turned out to be the answer:

<?php
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'view':
      $nid = ---insert your node id here---;
      if ($node->build_mode == NODE_BUILD_SEARCH_INDEX && $node->nid == $nid) {
        unset($node);
      }      
    break;
  }
}
?> 


The problem is that the search index follows 1) the access permissions. A module that hides single pages for users, is private module. A module that allows per-node access settings. Search will then follow the access settings and will hide the hidden page from search results.

1) technically not entirely correct


Module restrict_content is a perfect tool for what you need

0

精彩评论

暂无评论...
验证码 换一张
取 消