You are here

public function BlazyStylePluginTrait::getCaption in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/Dejavu/BlazyStylePluginTrait.php \Drupal\blazy\Dejavu\BlazyStylePluginTrait::getCaption()
  2. 8 src/Dejavu/BlazyStylePluginTrait.php \Drupal\blazy\Dejavu\BlazyStylePluginTrait::getCaption()

Returns the rendered caption fields.

1 call to BlazyStylePluginTrait::getCaption()
BlazyStylePluginBase::buildElement in src/Dejavu/BlazyStylePluginBase.php
Returns an individual row/element content.

File

src/Dejavu/BlazyStylePluginTrait.php, line 110

Class

BlazyStylePluginTrait
A Trait common for optional views style plugins for slick, etc.

Namespace

Drupal\blazy\Dejavu

Code

public function getCaption($index, $settings = []) {
  $items = [];
  $keys = array_keys($this->view->field);
  if (!empty($settings['caption'])) {

    // Exclude non-caption fields so that theme_views_view_fields() kicks in
    // and only render expected caption fields. As long as not-hidden, each
    // caption field should be wrapped with Views markups.
    $excludes = array_diff_assoc(array_combine($keys, $keys), $settings['caption']);
    foreach ($excludes as $field) {
      $this->view->field[$field]->options['exclude'] = TRUE;
    }
    $items['data'] = $this->view->style_plugin->row_plugin
      ->render($this->view->result[$index]);
  }
  $items['link'] = empty($settings['link']) ? [] : $this
    ->getFieldRendered($index, $settings['link']);
  $items['title'] = empty($settings['title']) ? [] : $this
    ->getFieldRendered($index, $settings['title'], TRUE);
  $items['overlay'] = empty($settings['overlay']) ? [] : $this
    ->getFieldRendered($index, $settings['overlay']);
  return $items;
}