本文整理汇总了PHP中Drupal\views\Plugin\views\style\StylePluginBase::render方法的典型用法代码示例。如果您正苦于以下问题:PHP StylePluginBase::render方法的具体用法?PHP StylePluginBase::render怎么用?PHP StylePluginBase::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Plugin\views\style\StylePluginBase
的用法示例。
在下文中一共展示了StylePluginBase::render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Overrides \Drupal\views\Plugin\views\style\StylePluginBase\StylePluginBase::render().
*/
public function render()
{
if (!empty($this->view->live_preview)) {
return parent::render();
}
// Group the rows according to the grouping field, if specified.
$sets = $this->renderGrouping($this->view->result, $this->options['grouping']);
// Grab the alias of the 'id' field added by
// entity_reference_plugin_display.
$id_field_alias = $this->view->storage->get('base_field');
// @todo We don't display grouping info for now. Could be useful for select
// widget, though.
$results = array();
$this->view->row_index = 0;
foreach ($sets as $records) {
foreach ($records as $values) {
// Sanitize HTML, remove line breaks and extra whitespace.
$output = $this->view->rowPlugin->render($values);
$output = drupal_render($output);
$results[$values->{$id_field_alias}] = Xss::filterAdmin(preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', $output)));
$this->view->row_index++;
}
}
unset($this->view->row_index);
return $results;
}
示例2: render
/**
* {@inheritdoc}
*/
public function render()
{
// Group the rows according to the grouping field, if specified.
$sets = parent::render();
// Render each group separately and concatenate.
$output = $sets;
foreach ($sets as $key => &$set) {
// Add caption field if chosen.
if (!empty($this->options['captionfield'])) {
$caption_field = $this->options['captionfield'];
foreach ($set['#rows'] as $index => $row) {
$set['#rows'][$index]['#caption'] = $this->rendered_fields[$index][$caption_field];
}
}
$output[$key] = ['#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#rows' => $set['#rows'], '#title' => $set['#title']];
}
return $output;
}