function _uniqueness_content_nodetitle in Uniqueness 6
Same name and namespace in other branches
- 7 uniqueness.module \_uniqueness_content_nodetitle()
Searches for related content by comparing the node title with the title of existing nodes.
1 call to _uniqueness_content_nodetitle()
- uniqueness_content in ./
uniqueness.module - Perform lookup of related or similar content.
File
- ./
uniqueness.module, line 384 - uniqueness.module
Code
function _uniqueness_content_nodetitle($values) {
$related_content = array();
// Query node table.
if ($values['title']) {
$where = array(
$values['title'],
);
$sql = "SELECT n.nid, n.title FROM {node} n WHERE LOWER(n.title) LIKE LOWER('%%%s%') AND n.status = 1";
if (array_key_exists('type', $values)) {
$sql .= " AND n.type = '%s'";
$where[] = $values['type'];
}
if (array_key_exists('type', $values) && is_numeric($values['nid'])) {
$sql .= " AND n.nid != %d";
$where[] = $values['nid'];
}
$result = db_query_range(db_rewrite_sql($sql), $where, 0, variable_get('uniqueness_results_max', 10) + 1);
// +1 for "... and more"
while ($row = db_fetch_array($result)) {
$related_content[$row['nid']] = $row;
}
}
return $related_content;
}