コード例 #1
0
ファイル: EntityReference.php プロジェクト: alnutile/drunatra
 /**
  * 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
0
ファイル: FlexSlider.php プロジェクト: r-daneelolivaw/chalk
 /**
  * {@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;
 }