Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save and1truong/3186636 to your computer and use it in GitHub Desktop.

Select an option

Save and1truong/3186636 to your computer and use it in GitHub Desktop.
Implements hook_nodequeue_autocomplete()
<?php
/**
* Implements hook_nodequeue_autocomplete().
*/
function smartqueue_og_nodequeue_autocomplete($queue, $subqueue, $string, $where, $where_args) {
// Disable language selection temporarily, enable it again later.
if (module_exists('i18n')) {
i18n_selection_mode('off');
}
$group_nid = $subqueue->reference;
$where_args[] = $group_nid;
$sql = "SELECT n.nid, n.title, n.tnid";
$sql .= " FROM {node} n INNER JOIN {og_ancestry} oga ON n.nid = oga.nid";
$sql .= " WHERE {$where} AND oga.group_nid = %d";
$result = db_query_range(db_rewrite_sql($sql), $where_args, 0, variable_get('nodequeue_autocomplete_limit', 10));
if (module_exists('i18n')) {
i18n_selection_mode('reset');
}
$matches = array();
while ($node = db_fetch_object($result)) {
$id = nodequeue_get_content_id($queue, $node);
$matches[$id] = check_plain($node->title) . " [nid: $id]";
}
return $matches;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment