views:

172

answers:

2

Hi, 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: http://stackoverflow.com/questions/1748837/hide-drupal-nodes-from-search, but that 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?

A: 

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

berkes
The page itself needs to be accessible to un-authenticated users (it's a form that's required for regulatory compliance), but we want only those who are directly invited to use it. So, it's not in our menus or linked to anywhere, but only given out as a direct link in email.Can't I just manually remove this from the index some how?
ilowe
Two things:1. Your go at this is wrong. If you want such invite-only things you really need a orivacy system. Private module is part of that solution, but you would need some sort of one-time hased url system. Otherwise it is security trough obscurity, wich is no security at all. Drupal will not help you with that.2. Because of 1. Drupal will not help you. Just deleting it from search is not possible, because Drupals indexing follows the access system. If you go for a "proper" system the page will not show up in the index (for people that cannot access the page). You get it "for free"
berkes
Thanks for the help, berkes. This site is currently maintenance only and will be redeveloped in the next couple of months, so we won't be implementing a privacy module for it.
ilowe
A: 

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;
  }
}
?> 
lazysoundsystem
This may work, but in some cases it will not. Problem is that nodeapi is only one of the hooks called during indexing. Some fields, e.g. offer information to the search index by themselves, resulting in the node being in the index again :). Besides, the node itself, albeit emty still sits in the index.An ugly solution, that may work :)
berkes
I'd like to know which are the other hooks involved here.
lazysoundsystem
...and why you think it's ugly.
lazysoundsystem