<?php
/**
 * Template Name: Stránka s odsekmi
 */

inoby_enqueue_parted_style("multitab_page", "page_templates");
inoby_enqueue_parted_script("multitab_page", "page_templates", ["glightbox"]);

get_header();

get_template_part("template-parts/yoast-breadcrumbs", "yoast-breadcrumbs");

$tabs = rwmb_meta("mt_page_tabs") ?? [];
$show_title = rwmb_meta("mt_page_show_title");
$show_content = rwmb_meta("mt_page_show_content");
?>
<main id="primary" class="site-main">
  <section class="multi-tab-page">
    <?php do_action("inoby_multitab_page_hero"); ?>
    <div class="container">
      <div class="row">
        <div class="col-3 col-lg-4 col-md-12">
          <ul class="left-side sticky-side-menu">
            <?php foreach ($tabs as $i => $tab): ?>
            <li class="sticky-side-menu-item"><a href="#tab-<?= $i ?>"><?= $tab[
  "mt_page_tab_title"
] ?? "" ?></a></li>
            <?php endforeach; ?>
          </ul>
        </div>
        <div class="col-9 col-lg-8 col-md-12">
          <div class="right-side">
            <div class="multitab-page-wrap">
              <?php if ($show_title): ?>
              <h2><?= the_title() ?></h2>
              <?php endif; ?>
              <?php if ($show_content): ?>
              <?= the_content() ?>
              <?php endif; ?>
              <?php foreach ($tabs as $i => $tab): ?>
              <div id="tab-<?= $i ?>" class="multitab-page-tab">
                <h3><?= $tab["mt_page_tab_title"] ?? "" ?></h3>
                <?php
                echo $tab["mt_page_tab_text"] ?? "";
                $images = $tab["mt_page_tab_images"] ?? [];
                if (!empty($images)) {
                  echo "<div class=\"gallery-wrap\">";
                  foreach ($images as $id) {

                    $thumb = wp_get_attachment_image_src($id, "s-2")[0] ?? "";
                    $large = wp_get_attachment_image_src($id, "s-12")[0] ?? "";
                    ?>
                <a class="gallery-img" href="<?= wp_get_attachment_image_src(
                  $id,
                  "full",
                )[0] ?? "" ?>"
                  style="background: center / cover no-repeat url(<?= wp_get_attachment_image_src(
                    $id,
                    "s-2",
                  )[0] ?? "" ?>);"></a>
                <?php
                  }
                  echo "</div>";
                }
                ?>
              </div>
              <?php endforeach; ?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</main>

<?php get_footer();
