You are here

function readmorecontrol_preprocess_search_result in Read More Control 7

Preprocessor for search result.

See also

search-result.tpl.php

File

./readmorecontrol.module, line 137
Defines options to control how the Read more link is displayed on teasers.

Code

function readmorecontrol_preprocess_search_result(&$variables) {

  // Best guess here, e.g. node or user.
  $type = $variables['module'];
  if (isset($variables['result'][$type]) && readmorecontrol_supported_entity($type)) {
    $entity = $variables['result'][$type];
    if (is_object($entity) && !empty($entity->readmorelink)) {
      if ($entity->readmore_required) {
        switch ($entity->readmorelink_placement) {
          case 'search_info':
            $variables['info_split'][] = $entity->readmorelink;
            if (empty($variables['info'])) {
              $variables['info'] = $entity->readmorelink;
            }
            else {
              $variables['info'] .= ' - ' . $entity->readmorelink;
            }
            break;
          default:
            $elm = strpos($entity->readmorelink_placement, '_inline') ? 'span' : 'div';
            $variables['snippet'] .= " <{$elm} class=\"read-more-link\">" . $entity->readmorelink . "</{$elm}>";
            break;
        }
      }
    }
  }
}