You are here

function template_preprocess_views_view_row_googlenews in Views Google News 8

Prepares variables for views Google News item templates.

Default template: views-view-row-googlenews.html.twig.

Parameters

array $variables: An associative array containing:

  • row: The raw results rows.

File

./views_googlenews.module, line 49
Views Google News module bootstrap file.

Code

function template_preprocess_views_view_row_googlenews(array &$variables) {
  $item = $variables['row'];

  // Allow item to be altered.
  \Drupal::moduleHandler()
    ->alter('views_googlenews_item', $item);
  $variables['loc'] = UrlHelper::filterBadProtocol($item['loc']);
  $variables['name']['#plain_text'] = $item['news_publication_name'];
  $variables['language']['#plain_text'] = $item['news_publication_language'];
  if (!empty($item['news_access'])) {
    $variables['access']['#plain_text'] = $item['news_access'];
  }
  if (!empty($item['news_genres'])) {
    $variables['genres']['#plain_text'] = $item['news_genres'];
  }
  if (!empty($item['news_publication_date'])) {
    $variables['publication_date'] = trim(strip_tags($item['news_publication_date']));
  }
  $variables['title']['#plain_text'] = strip_tags($item['news_title']);
  if (!empty($item['news_keywords'])) {
    $variables['keywords']['#plain_text'] = strip_tags($item['news_keywords']);
  }
  if (!empty($item['news_stock_tickers'])) {
    $variables['stock_tickers']['#plain_text'] = strip_tags($item['news_stock_tickers']);
  }
}