This is an old revision of the document!


Custom search result

  • Limit dc.description to 200 chars

Edit sites/all/modules/islandora_solr_custom/theme/islandora_solr_custom.theme.inc

function islandora_solr_custom_preprocess_islandora_solr_custom(&$variables) {
...

Tip

//  $variables['field_order'] = _islandora_solr_custom_solrconfig(); // not sure if this is really needed, but I'll keep it in for now.
...
      if ($field=="PID") {
        $hlv = $hl->$value;
        foreach ($hlv as $singlef) {
                $linee = "";
                foreach ($singlef as $linea) {
                        $linee = $linee."... ".$linea."... <br>";
                }
                $resultsArray['OCR.OCR']['value'] = $linee;
        }
      }

Tip

      if (($field=="dc.description")&&($value!="")) {
          $resultsArray[$field]['value'] = substr($value,0,200)."... ";
      }
      // set the fields
      $resultsArray[$field]['label'] = $db_value['label'];
      $resultsArray[$field]['class'] = strtolower( preg_replace('/[^A-Za-z0-9]/', '-', $db_value['field$
      $resultsArray[$field]['exclude_label'] = $db_value['exclude_label'];
      $resultsArray[$field]['markup'] = $db_value['markup'];
 
    }
...
  • Custom theme and layout

Edit sites/all/modules/islandora_solr_custom/theme/islandora-solr-custom.tpl.php

Tip

<?php// print $switch_rendered; ?>
<?php $style = 'table'; ?>
 
<?php if ($style == 'div'): ?>
<?php elseif ($style == 'table'): ?>
 
  <?php// print $table_rendered; ?>
  <?php if ($results == ''): print '<p>' . t('Your search yielded no results') . '</p>'; ?>
  <?php else: ?>
    <table class="islandora_solr_results">
    <?php foreach ($results as $id => $result): ?>
	<?php $modello = $result['rels.hasModel']['value']; ?>
	<?php if ($modello == "info:fedora/islandora:pageCModel"):?>
	  <tr class="islandora_solr_result">
	    <td class="label" rowspan="2">
              <?php print "<a href=\"".base_path()."fedora/repository/".substr($result['PID']['value'],0,-5)."\"><img src=\"".base_path()."fedora/repository/".substr($result['PID']['value'], 0, -5)."/TN\"></img></a>"; ?>
	    </td>
	    <td class="value">
	      <?php print "<b>".substr($result['dc.title']['value'],0,-12)."</b>"; ?><br><br>
              <i><?php print $result['dc.creator']['value']; ?></i><br>
              <i><?php print $result['dc.publisher']['value']; ?></i><br>
              <i><?php print $result['dc.description']['value']; ?></i><br>
	    </td>
	    <td class="plabel" rowspan="2">
              <?php print "<a href=\"".base_path()."fedora/repository/".$result['PID']['value']."\"><img height=\"150\" src=\"".base_path()."fedora/repository/".$result['PID']['value']."/TN\"></img></a>"; ?>
	      <?php print "<br><b>".substr($result['dc.title']['value'],-9)."</b>"; ?>
	    </td>
	  </tr>
	  <tr class="islandora_solr_result">
	    <td class="ocrvalue">
	      <?php print $result['OCR.OCR']['value']; ?>
	    </td>
	  </tr>
	<?php elseif ($modello == "info:fedora/islandora:bookCModel"): ?>
          <tr class="islandora_solr_result">
            <td class="label">
              <?php print "<a href=\"".base_path()."fedora/repository/".$result['PID']['value']."\"><img src=\"".base_path()."fedora/repository/".$result['PID']['value']."/TN\"></img></a>"; ?>
            </td>
	    <td class="value">
	      <?php print "<b>".$result['dc.title']['value']."</b>"; ?><br><br>
              <i><?php print $result['dc.creator']['value']; ?></i><br>
              <i><?php print $result['dc.publisher']['value']; ?></i><br>
              <i><?php print $result['dc.description']['value']; ?></i><br>
            </td>
          </tr>
        <?php endif; ?>
    <?php endforeach; ?>
    </table>
  <?php endif; ?>
<?php endif; ?>

Edit sites/all/modules/islandora_solr_custom/css/islandora_solr_custom_tpl.css

Tip

/* css markup for template */
 
.islandora_solr_result
{
  margin-bottom: 25px;
  border: 10px solid #fff;
  background: #fff url(images/bg-content.png) repeat-x 50% 0;
}
 
.islandora_solr_result .label
{
  width: 180px;
  padding: 10px 10px 0px 0px;
  vertical-align: top;
  text-align: right;
  background: #fff;
}
 
.islandora_solr_result .plabel
{
  width: 110px;
  padding: 0px 0px 0px 5px;
  vertical-align: bottom;
  text-align: left;
}
 
.islandora_solr_result .value
{
  padding: 10px 0px 0px 2px;
  vertical-align: top;
  text-align: left;
}
 
.islandora_solr_result .ocrvalue
{
  padding: 0px 5px 0px 5px;
  vertical-align: top;
  text-align: right;
  font-size:0.82em;
  background: #fff;
}

Copy bg-content.png to sites/all/modules/islandora_solr_custom/css/images/

 
 
frontend/searchres.1378373778.txt.gz ยท Last modified: 2013/09/05 11:36 by giancarlo

Developers: CNR IRCrES IT Office and Library
Giancarlo Birello (giancarlo.birello _@_ ircres.cnr.it) and Anna Perin (anna.perin _@_ ircres.cnr.it)
DigiBess is licensed under: Creative Commons License
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Drupal Garland Theme for Dokuwiki