function featured_content_get_search_string in Featured Content 7.2
Same name and namespace in other branches
- 6.2 featured_content.module \featured_content_get_search_string()
- 6 featured_content.module \featured_content_get_search_string()
- 7 featured_content.module \featured_content_get_search_string()
Get search string based on give node title.
2 calls to featured_content_get_search_string()
- featured_content_get_filtered_nids in ./
featured_content.module - Get filtered node nids. Filter base on content types, users (authors) and taxonomy terms.
- featured_content_get_search_nids in ./
featured_content.module - Get search result node nids. Uses the title of the current node page to get the search results.
File
- ./
featured_content.module, line 1853 - Featured Content module for created related & featured content blocks.
Code
function featured_content_get_search_string($node, $num_words) {
$keyword_search_string = '';
if (!empty($node) && !empty($node->title)) {
// If title trimming is enabled, pull out the first x significantly
// long words in the title.
if ($num_words > 0) {
$search_terms = array();
$found_terms = 0;
$min_length_for_search_term = variable_get('minimum_word_size', 3);
foreach (explode(' ', $node->title) as $word_position => $word) {
if (count($search_terms) < $num_words) {
$processed_word = search_simplify($word);
if (mb_strlen($processed_word) > $min_length_for_search_term) {
$search_terms[] = $word;
++$found_terms;
}
}
}
$keyword_search_string = implode(' ', $search_terms);
}
else {
$keyword_search_string = $node->title;
}
}
return $keyword_search_string;
}