ADCI Solutions
Published in

ADCI Solutions

Adding filtering by Nodequeue name in Search API Views

By ADCI Solutions
/**
* Implements hook_entity_property_info_alter().
*/
function my_module_entity_property_info_alter(&$info) {
$info['node']['bundles']['node_bundle']['properties']['queue_name'] = array(
'type' => 'list<string>',
'options list' => '_my_module_nodequeue_options_list',
'label' => 'Nodequeue name',
'getter callback' => '_my_module_get_nodequeue_name',
'description' => t('A name of a nodequeue that node is attached.'),
'entity views field' => TRUE,
);
}
/**
* Returns all node queues which works with property nodes.
*/
function _queue_name_nodequeue_options_list() {
$nq_names = array();
$node_queues = nodequeue_load_queues(array_keys(nodequeue_get_all_qids()));
foreach ($node_queues as $key => &$node_queue) {
$nq_names[$node_queue->name] = $node_queue->title;
}
return $nq_names;
}
/**
* Get queue name for node.
*/
function _queue_name_get_nodequeue_name($node, $options, $name, $entity_type, $info) {
$nq_names = array();
$node_queues = nodequeue_load_queues(array_keys(nodequeue_get_all_qids()));
foreach ($node_queues as $key => &$node_queue) {
if (nodequeue_queue_position($node_queue->qid, $node->nid)) {
$nq_names[] = $node_queue->name;
}
}
return $nq_names;
}

--

--

ADCI Solutions notes on development, design and people who are involved

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ADCI Solutions

We help businesses thrive online and get to the market faster than their competitors. https://www.adcisolutions.com/