Browse Source

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

2.x-ebsco
Paul Pound 10 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 = { Drupal.behaviors.roblib_search_solr_site_bestbet = {
attach: function(context, settings) { attach: function(context, settings) {
$url = settings.roblib_search_solr_site_bestbet.search_url; url = settings.roblib_search_solr_site_bestbet.search_url;
jQuery.getJSON($url, function(data) { jQuery.getJSON(url, function(data) {
var items = []; var items = [];
var numberOfDocs = 0; var numberOfDocs = 0;
try { 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) { 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(); exit();
} }
@ -231,6 +233,29 @@ function roblib_search_solr_site_guides($query) {
exit(); 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 * @param string $query

Loading…
Cancel
Save