_nodereference_potential_references_standard manipulieren
am 16.05.2011 - 20: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 4 Wochen 5 Tagen
vor 5 Wochen 2 Tagen
vor 5 Wochen 2 Tagen
vor 7 Wochen 5 Tagen
vor 8 Wochen 10 Stunden
vor 8 Wochen 21 Stunden
vor 8 Wochen 3 Tagen
vor 11 Wochen 5 Tagen
vor 11 Wochen 4 Tagen
vor 11 Wochen 4 Tagen