Created
July 2, 2013 16:20
-
-
Save pierrenel/5910768 to your computer and use it in GitHub Desktop.
Exclude a type of content from drupal search results, + limit to 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Excludes node type "foo" from search results | |
* | |
* @param object $query | |
*/ | |
function mymodule_query_alter(&$query) { | |
$is_search = FALSE; | |
foreach ($query->getTables() as $table) { | |
if ($table['table'] == 'search_index') { | |
$is_search = TRUE; | |
} | |
} | |
if ($is_search) { | |
$query->condition('n.type', 'foo', '<>') | |
->range(0,8); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment