How to render programmatically a quicktab in drupal 8

Created on 21 April 2017, about 7 years ago
Updated 11 August 2020, almost 4 years ago

Hello, thank you very much for this great module, in drupal 7 for programmatically render quicktabs i usually do :

   $qtname = 'quicktab_machine_name';
   $quicktab_to_render = quicktabs_build_quicktabs($qtname);
   print drupal_render($quicktab_to_render);

What is the best way to do the same in drupal 8 ? in my route (or in my twig template) but with the new drupal 8 version?

Thank you very much

💬 Support request
Status

Active

Component

Code

Created by

🇮🇹Italy rafuel92

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India sadashiv

    I was trying to do something similar, I ended up,
    1) Create a quicktabs using UI
    2) In code $qt = \Drupal\quicktabs\Entity\QuickTabsInstance::load('QT_ID');
    3)

    $configuration_data = [
          [
            'title'=> 'Node 1',
            'weight'=> 0,
            'type' => 'node_content',
            'content' => [
              'node_content' => [
                'options' => [
                  'nid' => '1',
                  'view_mode' => 'full',
                  'hide_title' => true,
                ],
              ],
            ],
          ],
          [
            'title'=> 'Node', 2
            'weight'=> 1,
            'type' => 'node_content',
            'content' => [
              'node_content' => [
                'options' => [
                  'nid' => '2',
                  'view_mode' => 'full',
                  'hide_title' => true,
                ],
              ],
            ],
          ],
        ];

    Simple try is to configure the qt using UI and check the export and form this configuration array
    4) $qt->setConfigurationData($configuration_data);
    5) $qt->getRenderArray() returns the rederer array which can then be returned or passed through drupal renderer.

    Thanks,
    Sadashiv.

Production build 0.69.0 2024