<?php
if ($categories) {
  echo '<div class="row row-cols-3 row-cols-sm-4 row-cols-md-6 bg-light g-1 g-sm-2 mb-3">';
  $cnt = 0;
  $thumbsize = explode('x', CARD_THUMB);
  foreach ($categories as $cat) {
    $cnt++;
    if ($cat['thumb']) {
      $thumb = APP_URL . '/upload_file/folderthumb/' . CARD_THUMB . '/' . $cat['thumb'];
    } else {
      $thumb = APP_URL . '/assets/images/folder.svg';
    }
    if ($cat['is_cat'] == 1) {
      $list_href = 'category';
      $catYear = '';
    } else {
      $list_href = 'album';
      $catYear = ($cat['release_year'])?' ('.$cat['release_year'].')':'';
    }
    $catName = ($catYear)?$cat['name'].' <span>(' . $cat['release_year'].')</span>':$cat['name'];
    echo '<div class="col">
   <a data-bs-toggle="tooltip" title="' . $cat['name'] . $catYear. '" href="' . APP_URL . '/' . $list_href . '/' . $cat['slug'] . $endRoute . '" class="card movie">
     <img src="' . APP_URL . '/assets/images/folder.svg" data-src="' . $thumb . '" class="lazy card-img-top" alt="' . $cat['name']. $catYear . '">
     <div class="movie-body">
       <h4>' . $catName.'</h4>
       <span>Total: ' . $cat['totalitem'] . '</span>
     </div>
   </a>
 </div>';
    if ($cnt % ADVT_EACH == 0) {
      echo getAds($AdsPath . '/between_catlist');
    }
  }
  unset($categories);
  unset($thumbsize);
  echo '</div>';
}