You are here

public function QuickAccordion::render in Quick Tabs 7.3

The only method that renderer plugins must implement.

Return value

A render array to be passed to drupal_render().

Overrides QuickRenderer::render

File

plugins/QuickAccordion.inc, line 33

Class

QuickAccordion
Renders the content using the jQuery UI Accordion widget.

Code

public function render() {
  $quickset = $this->quickset;
  $qsid = 'quickset-' . $quickset
    ->getName();

  // Build our render array...
  $render_array = array();
  $render_array['#attached'] = $this
    ->add_attached();
  $render_array['content'] = array(
    '#theme' => 'qt_accordion',
    '#options' => array(
      'attributes' => array(
        'id' => $qsid,
        'class' => array(
          'quick-accordion',
        ),
      ),
    ),
    'divs' => array(),
  );

  // Render all tab content.
  foreach ($quickset
    ->getContents() as $key => $item) {
    if (!empty($item)) {
      $attributes = array();
      $attributes['class'][] = drupal_html_class($item
        ->getTitle());
      drupal_alter('quicktabs_tablinks_attributes', $attributes, $quickset, $key);
      $attributes['href'] = '#' . $qsid . '_' . $key;
      $render_array['content']['divs'][] = array(
        '#prefix' => '<h3><a ' . drupal_attributes($attributes) . '>' . check_plain($quickset
          ->translateString($item
          ->getTitle(), 'tab', $key)) . '</a></h3><div>',
        '#suffix' => '</div>',
        'content' => $item
          ->render(),
      );
    }
  }
  return $render_array;
}