File "content.phtml"

Full Path: /www/wwwroot/turbocarclub.com/themes/dorado/layout/category/content.phtml
File size: 6.96 KB
MIME-type: --
Charset: utf-8

<?php
global $zon, $site_url;
// $category_name = urldecode(htmlspecialchars($_GET['n'] ?? $zon['page'][1]));
// $category_name = $_GET['n'] ?? $zon['page'][1];
$results_per_page = 15; // Number of results per page
$links_to_show = 3; // Number of links to show
$category_name = uSlug($zon['page'][0] ?? $_GET['u']);
$category = CategoryDataBySlug($category_name);

$total_results = count(GameByCategoryNameWithPagination($category['id']));

$total_pages = ceil($total_results / $results_per_page);
// Determine which page number visitor is currently on
if (!isset($_GET['page'])) {
    $page = 1;
} else {
    $page = $_GET['page'];
}
// Determine the SQL LIMIT starting number for the results on the displaying page
$this_page_first_result = ($page - 1) * $results_per_page;

// Retrieve the selected results from the database
$pag_code = " LIMIT " . $this_page_first_result . ',' . $results_per_page;

?>
<h1 class="text-3xl capitalize mb-12 mt-12 block text-[var(--common-color)] page-heading">
    <?php echo $category['name'] ?>
</h1>
<!-- <div id="zon_games" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6 gap-6"></div> -->
<div class="grid grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
    <?php foreach (GameByCategoryNameWithPagination($category['id'], $pag_code) as $game) {
        $cn = $game['game_category'];
        $c = runner("SELECT * FROM zon_category WHERE name='$cn'")[0];
        $game['slug'] = $c['slug'];
        ?>
        <div class="game-card wow <?php echo $zon['config']['animate_class'] ?>">
            <a data-ajax="true" data-href="/<?= $game['game_slug'] ?>" href="<?= $site_url . $game['game_slug'] ?>" data-logo-src="<?= $zon['logo'] ?>"
                class="h-[120px] game-poster">
                <div class="loader">
                    <div class="fadeLogo">
                        <img src="<?= $zon['logo'] ?>" />
                    </div>
                </div>
                <img src="<?= $game['game_banner_url'] === '' ? $game['game_image_url'] : $game['game_banner_url'] ?>"
                    onerror="this.previousElementSibling.classList.add('active')" loading="lazy"
                    alt="<?= $game['game_name'] ?>" />

                <?php if ($game['game_played'] == 0) { ?>
                    <div class="badge new">
                        <svg width="20px" height="20px" stroke-width="2" viewBox="0 0 24 24" fill="none"
                            xmlns="http://www.w3.org/2000/svg" color="#000000">
                            <path
                                d="M15.8189 13.3287L10.4948 19.3183C9.69924 20.2134 8.30076 20.2134 7.50518 19.3183L2.18109 13.3287C1.50752 12.571 1.50752 11.429 2.18109 10.6713L7.50518 4.68167C8.30076 3.78664 9.69924 3.78664 10.4948 4.68167L15.8189 10.6713C16.4925 11.429 16.4925 12.571 15.8189 13.3287Z"
                                stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            </path>
                            <path
                                d="M12 6.375L13.5052 4.68167C14.3008 3.78664 15.6992 3.78664 16.4948 4.68167L21.8189 10.6713C22.4925 11.429 22.4925 12.571 21.8189 13.3287L16.4948 19.3183C15.6992 20.2134 14.3008 20.2134 13.5052 19.3183L12 17.625"
                                stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            </path>
                        </svg>
                    </div>
                <?php } ?>
                <div class="played-badge">
                    <svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path
                            d="M32 18H16C9.37258 18 4 23.3726 4 30C4 36.6274 9.37258 42 16 42H32C38.6274 42 44 36.6274 44 30C44 23.3726 38.6274 18 32 18Z"
                            fill="none" stroke="#000000" stroke-width="2" stroke-linejoin="round" />
                        <path d="M16 26V34" stroke="#000000" stroke-width="2" stroke-linecap="round"
                            stroke-linejoin="round" />
                        <path d="M12 30H20" stroke="#000000" stroke-width="2" stroke-linecap="round"
                            stroke-linejoin="round" />
                        <path d="M24 16V9.71429H32V4" stroke="#000000" stroke-width="2" stroke-linecap="round"
                            stroke-linejoin="round" />
                        <path
                            d="M32 34C34.2091 34 36 32.2091 36 30C36 27.7909 34.2091 26 32 26C29.7909 26 28 27.7909 28 30C28 32.2091 29.7909 34 32 34Z"
                            fill="none" stroke="#000000" stroke-width="2" stroke-linejoin="round" />
                    </svg>
                    <span><?= $game['game_played'] ?></span>
                </div>
            </a>
            <div class="game-details flex flex-col px-2 mt-2">
                <a data-ajax="true" data-href="/<?= $game['game_slug'] ?>" class="text-2xl text-[var(--common-color)] game-name"
                    href="<?= $site_url . $game['game_slug'] ?>"><?= $game['game_name'] ?></a>
                <a data-ajax="true" data-href="/<?= $game['slug'] ?>" class="text-md text-[var(--common-color-muted)] mt-1 capitalize"
                    href="<?= $site_url . $game['slug'] ?>"><?= $game['game_category'] ?></a>
            </div>
        </div>
    <?php } ?>
</div>

<div class="flex gap-4 justify-center pagination mt-32">
    <?php
    // Determine the range of page links to show
    $start_link = max(1, $page - floor($links_to_show / 2));
    $end_link = min($total_pages, $start_link + $links_to_show - 1);

    // Adjust start_link if necessary
    if ($end_link - $start_link < $links_to_show - 1) {
        $start_link = max(1, $end_link - $links_to_show + 1);
    }

    // Display pagination links
    if ($page > 1) { ?>
        <a class="py-2 px-6 rounded-lg hover:bg-[var(--theme-color)] bg-[var(--sidebar-option-hover-bg-color)] text-[var(--common-color)]"
            href="?page=<?= ($page - 1) ?> ">&LeftArrow;</a>
    <?php }

    for ($i = $start_link; $i <= $end_link; $i++) {
        if ($i == $page) { ?>
            <a href="?page=<?= $i ?>"
                class="py-2 <?= $page == $i ? 'active' : '' ?> px-6 rounded-lg hover:bg-[var(--theme-color)] bg-[var(--sidebar-option-hover-bg-color)] text-[var(--common-color)]"><?= $i ?></a>
        <?php } else { ?>
            <a href="?page=<?= $i ?>"
                class="py-2 <?= $page == $i ? 'active' : '' ?> px-6 rounded-lg hover:bg-[var(--theme-color)] bg-[var(--sidebar-option-hover-bg-color)] text-[var(--common-color)]"><?= $i ?></a>
        <?php }
    }
    ?>
    <?php
    if ($page < $total_pages) { ?>
        <a class="py-2 px-6 rounded-lg hover:bg-[var(--theme-color)] bg-[var(--sidebar-option-hover-bg-color)] text-[var(--common-color)]"
            href="?page=<?= ($page + 1) ?>">&RightArrow;</a>
    <?php }

    ?>
</div>