I'm trying to configure a search page from Apache Solr module, and add some custom fields to the items. Here is the code I'm using for this

Custom module:

function hook_apachesolr_query_alter($query) {
$query->addParam('fl', 'ts_field_up_short_description');}

Function in tamplate.php:

function tamplate_preprocess_search_result(&$variables) {
$variables['ts_field_up_short_description'] = $variables['result']['fields']['ts_field_up_short_description'];}

Display field in search-result.tpl.php:

<?php if ($ts_field_up_short_description) : ?>
     <?php print $ts_field_up_short_description; ?>
<?php endif; ?>

I'v created 3 nodes with this field, but only one of them displays the short description field (if displaying the search results with views everything is fine). Please tell me am I missing something? Thanks


1 Answer 1


I have forgotten to add the content type filters, everything is correct now. Another (better) way is to modify the snippet in module (like here) instead of the search results template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.