Same name in other branches
  1. 7.x-3.x plugins/QuickAccordion.inc \QuickAccordion::render()

Return value

array

Overrides QuickRenderer::render

Fichier

src/Plugin/QuickRender/QuickAccordion.php, line 48

Classe

QuickAccordion
Renders the content using the jQuery UI Accordion widget.

Namespace

Drupal\quicktabs\Plugin\QuickRender

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)) {
            $render_array['content']['divs'][] = array(
                '#prefix' => '<h3><a href= "#' . $qsid . '_' . $key . '">' . SafeMarkup::checkPlain($quickset->translateString($item->getTitle(), 'tab', $key)) . '</a></h3><div>',
                '#suffix' => '</div>',
                'content' => $item->render(),
            );
        }
    }
    return $render_array;
}