Browse Source

Add logic to allow trim title and authors.

roblib
Francisco J. Seva 7 years ago
parent
commit
e3a1b3bf61
  1. 26
      ebsco/ebsco.module
  2. 14
      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'];
}

14
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)));
@ -265,7 +275,7 @@
echo "</p>";
}
elseif ($record->title){
echo '<a href="' . $recordUrl . '" class="title _record_link">' . $record->title . '</a>';
echo '<a href="' . $recordUrl . '" class="title">' . $record->title . '</a>';
}
?>
</div>
@ -290,7 +300,7 @@
echo '<cite>' . $record->summary . '</cite><br />';
}
if (!empty($record->subjects)){
if (!empty($record->subjects) && !$hide_record_subject){
echo '<strong>' . t('Subjects') . '</strong>:<span class="quotestart">' . str_replace('<br />', ', ', $record->subjects) . '</span>';
}

Loading…
Cancel
Save