public function JsonFeedFields::render in JSON Feed 8
Render a row object. This usually passes through to a theme template of some form, but not always.
Parameters
object $row: A single row of the query result, so an element of $view->result.
Return value
string The rendered output of a single row, used by the style plugin.
Overrides RowPluginBase::render
File
- src/
Plugin/ views/ row/ JsonFeedFields.php, line 206
Class
- JsonFeedFields
- Plugin which displays fields for a JSON feed.
Namespace
Drupal\json_feed\Plugin\views\rowCode
public function render($row) {
// Create the JSON item.
$item = [];
$row_index = $this->view->row_index;
$item['id'] = strip_tags($this
->getField($row_index, $this->options['id_field']));
$item['url'] = strip_tags($this
->getAbsoluteUrlForField($row_index, 'url_field'));
$item['external_url'] = strip_tags($this
->getAbsoluteUrlForField($row_index, 'external_url_field'));
$item['title'] = strip_tags($this
->getField($row_index, $this->options['title_field']));
$item['content_html'] = $this
->getField($row_index, $this->options['content_html_field']);
$item['content_text'] = strip_tags($this
->getField($row_index, $this->options['content_text_field']));
$item['summary'] = strip_tags($this
->getField($row_index, $this->options['summary_field']));
$item['image'] = strip_tags($this
->getAbsoluteUrlForField($row_index, 'image_field'));
$item['banner_image'] = strip_tags($this
->getAbsoluteUrlForField($row_index, 'banner_image_field'));
$item['date_published'] = strip_tags($this
->getField($row_index, $this->options['date_published_field']));
$item['date_modified'] = strip_tags($this
->getField($row_index, $this->options['date_modified_field']));
$item['author'] = array_map('strip_tags', $this
->getAuthor($row_index, $this->options));
$item['tags'] = array_map('strip_tags', $this
->getTags($row_index, $this->options['tags_field']));
// Remove empty attributes.
$item['author'] = array_filter($item['author']);
$item = array_filter($item);
return $item;
}