баги с превью
This commit is contained in:
@@ -5,8 +5,19 @@ declare(strict_types=1);
|
||||
/** @var array<int, array<string, mixed>> $categories */
|
||||
/** @var array<string, mixed>|null $currentCategory */
|
||||
/** @var array<int, array<string, mixed>> $products */
|
||||
/** @var array<string, mixed> $pagination */
|
||||
|
||||
$heading = $currentCategory['h1'] ?? $currentCategory['name'] ?? 'Каталог продукции';
|
||||
$pagination = $pagination ?? [
|
||||
'base_path' => '/catalog',
|
||||
'total' => count($products),
|
||||
'shown' => count($products),
|
||||
'page' => 1,
|
||||
'pages' => 1,
|
||||
'per_page' => 48,
|
||||
'has_more' => false,
|
||||
'next_limit' => count($products),
|
||||
];
|
||||
?>
|
||||
<section class="catalog-layout">
|
||||
<aside class="catalog-sidebar">
|
||||
@@ -37,11 +48,31 @@ $heading = $currentCategory['h1'] ?? $currentCategory['name'] ?? 'Каталог
|
||||
<p class="muted">В этой категории товары появятся после переноса каталога со старого сайта.</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="catalog-count-panel">
|
||||
<span>Показано <?= e((string) $pagination['shown']) ?> из <?= e((string) $pagination['total']) ?> товаров</span>
|
||||
<?php if (!empty($pagination['has_more'])): ?>
|
||||
<a href="<?= e((string) $pagination['base_path']) ?>?limit=<?= e((string) $pagination['next_limit']) ?>">Показать еще</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="product-grid catalog-product-grid">
|
||||
<?php foreach ($products as $product): ?>
|
||||
<?php require base_path('views/partials/product-card.php'); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ((int) $pagination['pages'] > 1): ?>
|
||||
<nav class="catalog-pagination" aria-label="Страницы каталога">
|
||||
<?php for ($pageNumber = 1; $pageNumber <= (int) $pagination['pages']; $pageNumber++): ?>
|
||||
<a
|
||||
class="<?= $pageNumber === (int) $pagination['page'] && empty($pagination['cumulative']) ? 'is-current' : '' ?>"
|
||||
href="<?= e((string) $pagination['base_path']) ?>?page=<?= e((string) $pageNumber) ?>"
|
||||
>
|
||||
<?= e((string) $pageNumber) ?>
|
||||
</a>
|
||||
<?php endfor; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user