diff --git a/targets/solr_site/js/solr_site_bestbet.js b/targets/solr_site/js/solr_site_bestbet.js index d505f9e..033eab9 100755 --- a/targets/solr_site/js/solr_site_bestbet.js +++ b/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 { diff --git a/targets/solr_site/roblib_search_solr_site.module b/targets/solr_site/roblib_search_solr_site.module index bd4867c..638d4ff 100755 --- a/targets/solr_site/roblib_search_solr_site.module +++ b/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