_nodereference_potential_references_standard manipulieren
am 16.05.2011 - 19:47 Uhr in
Weiß jemand, wie ich diese Funktion aus nodereference.module ändern muss, damit auch Nodes gefunden werden, die die Suchbegriffe nicht als String enthalten? So dass z.B. die Node mit dem Titel "foo bar magic" gefunden wird, wenn der User "foo magic" ins nodereference-Feld eingibt.
<?php
function _nodereference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
$related_types = array();
$where = array();
$args = array();
if (is_array($field['referenceable_types'])) {
foreach (array_filter($field['referenceable_types']) as $related_type) {
$related_types[] = "n.type = '%s'";
$args[] = $related_type;
}
}
$where[] = implode(' OR ', $related_types);
if (!count($related_types)) {
return array();
}
if ($string !== '') {
$like = $GLOBALS["db_type"] == 'pgsql' ? "ILIKE" : "LIKE";
$match_clauses = array(
'contains' => "$like '%%%s%%'",
'equals' => "= '%s'",
'starts_with' => "$like '%s%%'",
);
$where[] = 'n.title '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
$args[] = $string;
}
elseif ($ids) {
$where[] = 'n.nid IN (' . db_placeholders($ids) . ')';
$args = array_merge($args, $ids);
}
$where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
$sql = db_rewrite_sql("SELECT n.nid, n.title AS node_title, n.type AS node_type FROM {node} n $where_clause ORDER BY n.title, n.type");
$result = $limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args);
$references = array();
while ($node = db_fetch_object($result)) {
$references[$node->nid] = array(
'title' => $node->node_title,
'rendered' => check_plain($node->node_title),
);
}
return $references;
}
?>- Anmelden oder Registrieren um Kommentare zu schreiben

Neue Kommentare
vor 16 Stunden 26 Minuten
vor 1 Woche 4 Tagen
vor 1 Woche 5 Tagen
vor 9 Wochen 2 Tagen
vor 9 Wochen 3 Tagen
vor 9 Wochen 3 Tagen
vor 10 Wochen 1 Tag
vor 10 Wochen 1 Tag
vor 10 Wochen 5 Tagen
vor 10 Wochen 5 Tagen