<?php

/*
 * Content blocks with sidebar
 */
$description_tabs = [];
if (!empty($p->pagedata['Content Sections'])) {
    //Loop each content section
    foreach ($p->pagedata['Content Sections'] as $row) {

        //Build array content
        $title   = $row['Title']['value'];
        $content = $row['Content']['value'];

        //Add to tabs is content exists
        if (!empty($title) && !empty($content)) {

            $description_tabs[] = [
                'title'   => $title,
                'content' => $content
            ];

        }

    }

    //Set twig variable to use in template
    $twig->addGlobal('tabs_from_controller', $description_tabs);
}

