Browse Source

updated the bestbet so it links directly to the target of the link field

2.x-ebsco
Paul Pound 11 years ago
parent
commit
faf4abf04c
  1. 4
      targets/solr_site/js/solr_site_bestbet.js
  2. 27
      targets/solr_site/roblib_search_solr_site.module

4
targets/solr_site/js/solr_site_bestbet.js

@ -1,7 +1,7 @@
Drupal.behaviors.roblib_search_solr_site_bestbet = {
attach: function(context, settings) {
$url = settings.roblib_search_solr_site_bestbet.search_url;
jQuery.getJSON($url, function(data) {
url = settings.roblib_search_solr_site_bestbet.search_url;
jQuery.getJSON(url, function(data) {
var items = [];
var numberOfDocs = 0;
try {

27
targets/solr_site/roblib_search_solr_site.module

@ -217,7 +217,9 @@ function roblib_search_solr_site_results($query) {
}
function roblib_search_solr_site_bestbet($query) {
print roblib_search_solr_site_get_results($query, 'bundle:bestbet');
$json = roblib_search_solr_site_get_results($query, 'bundle:bestbet');
$json = roblib_search_solr_site_add_url($json);
print $json;
exit();
}
@ -231,6 +233,29 @@ function roblib_search_solr_site_guides($query) {
exit();
}
/**
*
* Updates the json passed in with a url directly to the target of the link field.
* This information is not in solr as it comes from a custom field.
*
* @param string $json
* The json string returned from the solr query.
*
* @return string
* json we got from solr with an updated url directly to the target of the link field
*/
function roblib_search_solr_site_add_url($json) {
$responses = json_decode($json);
foreach ($responses->response->docs as &$doc) {
$nid = $doc->entity_id;
$node = node_load($nid);
$url = $node->field_link['und'][0]['url'];
$doc->url = $url;
}
return json_encode($responses);
}
/**
*
* @param string $query

Loading…
Cancel
Save