Browse Source

Merge pull request #8 from BluesparkLabs/trim-title-authors

Thank you for the contributions Fran. changes have been merged
roblib
Rui Francisco 7 years ago committed by GitHub
parent
commit
c4f66a5fed
  1. 26
      ebsco/ebsco.module
  2. 10
      ebsco/templates/ebsco-results.tpl.php

26
ebsco/ebsco.module

@ -68,6 +68,10 @@ function ebsco_theme() {
),
'ebsco_results' => array(
'template' => 'templates/ebsco-results',
'variables' => array(
'trim_title' => FALSE,
'trim_authors' => FALSE,
),
),
'ebsco_side_facets' => array(
'template' => 'templates/ebsco-side-facets',
@ -216,6 +220,25 @@ function ebsco_admin() {
'#required' => TRUE,
);
$form['ebsco_general']['ebsco_title_trim'] = array(
'#type' => 'textfield',
'#title' => t('Trim result Title'),
'#default_value' => variable_get('ebsco_title_trim', 0),
'#size' => 3,
'#maxlength' => 3,
'#description' => t('Title maximum number of characters to be displayed when an item is render in search result page.'),
'#required' => TRUE,
);
$form['ebsco_general']['ebsco_authors_trim'] = array(
'#type' => 'textfield',
'#title' => t('Trim result Authors'),
'#default_value' => variable_get('ebsco_authors_trim', 0),
'#size' => 3,
'#maxlength' => 3,
'#description' => t('Authors maximum number of characters to be displayed when an item is render in search result page.'),
'#required' => TRUE,
);
return system_settings_form($form);
}
@ -904,6 +927,9 @@ function template_preprocess_ebsco_results(&$variables) {
$variables['relatedContent'] = $_ebsco_document->relatedContent();
$variables['autoSuggestTerms'] = $_ebsco_document->autoSuggestTerms();
$variables['lookfor'] = '';
$variables['trim_title'] = variable_get('ebsco_title_trim', 0);
$variables['trim_authors'] = variable_get('ebsco_authors_trim', 0);
if (isset($params['lookfor'])) {
$variables['lookfor'] = $params['lookfor'];
}

10
ebsco/templates/ebsco-results.tpl.php

@ -230,6 +230,16 @@
<ol class="search-results ebsco">
<?php foreach ($records as $record):
// Trim Title if needed.
if ($trim_title && strlen($record->title) > $trim_title) {
$record->title = truncate_utf8($record->title, $trim_title, TRUE, TRUE, 1);
}
// Trim Authors if needed.
if ($trim_authors && strlen($record->authors) > $trim_authors) {
$record->authors = truncate_utf8(implode(',',explode('<br />', $record->authors)), $trim_authors, TRUE, TRUE, 1);
}
$id = check_plain($record->record_id());
$recordUrl = url('ebsco/result', array('query' => array('id' => $id)));
$fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id)));

Loading…
Cancel
Save