/
mnt
/
www
/
animaux-de-jardin.fr
/
Upload File
HOME
<?php /** * CATEGORY PARAMETRIQUE — 6 styles * * Variable attendue dans config.php : * $category_style : classic|magazine|list|minimal|banner|cards_horizontal * * Variables classiques : * $category (slug), $categories (array), $site_name */ require __DIR__ . '/config.php'; require_once __DIR__ . '/parts/picture.php'; $cat_info = $categories[$category] ?? null; if (!$cat_info) { http_response_code(404); echo 'Not found'; exit; } $active_category = $category; $page_title = $cat_info['name']; $page_description = $cat_info['description'] . ' - ' . $site_name; // Collect articles via meta_only pattern $articles = []; $files = glob(__DIR__ . '/' . $category . '/*.php'); foreach ($files as $file) { $filename = basename($file); if ($filename === 'index.php') continue; $article_meta = null; $meta_only = true; include $file; if ($article_meta) { $article_meta['filename'] = $filename; $article_meta['mtime'] = filemtime($file); $articles[] = $article_meta; } } usort($articles, function($a, $b) { return $b['mtime'] - $a['mtime']; }); unset($article_meta, $meta_only); // og:image = image du premier article (le plus recent) if (!empty($articles[0]['image'])) { $page_og_image = 'https://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . '/images/' . $articles[0]['image'] . '-1920.jpg'; } include __DIR__ . '/parts/header.php'; // Category style (default: classic = identical to original) $category_style = $category_style ?? 'classic'; ?> <div class="category-<?php echo $category_style; ?>"> <?php if ($category_style === 'classic'): ?> <section class="category-hero"> <div class="category-hero-inner"> <div class="breadcrumb"><a href="/"><?php echo $lang['home'] ?? 'Accueil'; ?></a> › <?php echo htmlspecialchars($cat_info['name']); ?></div> <div class="category-icon"><?php echo $cat_info['icon']; ?></div> <h1><?php echo htmlspecialchars($cat_info['name']); ?></h1> <p><?php echo htmlspecialchars($cat_info['description']); ?></p> </div> </section> <section class="articles-section"> <?php if (empty($articles)): ?> <div class="empty-state"> <div class="empty-state-icon"><?php echo $cat_info['icon']; ?></div> <h2> </h2> <p> </p> </div> <?php else: ?> <div class="articles-grid"> <?php foreach ($articles as $article): ?> <article class="article-card"> <a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"> <div class="article-card-image"> <?php picture($article['image'], $article['title'], '(max-width: 640px) 100vw, (max-width: 968px) 50vw, 33vw'); ?> <span class="article-card-tag"><?php echo htmlspecialchars($cat_info['name']); ?></span> </div> </a> <div class="article-card-body"> <h2><a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"><?php echo htmlspecialchars($article['title']); ?></a></h2> <?php if (!empty($article['intro'])): ?> <p><?php echo htmlspecialchars(mb_substr($article['intro'], 0, 150)); ?>...</p> <?php endif; ?> <div class="article-card-meta"> <?php if (!empty($article['date'])): ?> <span><?php echo htmlspecialchars($article['date']); ?></span> <?php endif; ?> <span class="article-card-read"><?php echo htmlspecialchars($article['read_time'] ?? '5'); ?> <?php echo $lang['read_time'] ?? 'min de lecture'; ?> →</span> </div> </div> </article> <?php endforeach; ?> </div> <?php endif; ?> </section> <?php elseif ($category_style === 'magazine'): ?> <section class="category-hero-compact"> <div class="breadcrumb"><a href="/"><?php echo $lang['home'] ?? 'Accueil'; ?></a> › <?php echo htmlspecialchars($cat_info['name']); ?></div> <h1><?php echo htmlspecialchars($cat_info['name']); ?></h1> <p><?php echo htmlspecialchars($cat_info['description']); ?></p> </section> <section class="articles-section"> <?php if (empty($articles)): ?> <div class="empty-state"> <div class="empty-state-icon"><?php echo $cat_info['icon']; ?></div> <h2> </h2> <p> </p> </div> <?php else: ?> <?php $featured = $articles[0]; $rest = array_slice($articles, 1); ?> <article class="article-featured"> <a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($featured['filename']); ?>"> <div class="article-featured-image"> <?php picture($featured['image'], $featured['title'], '(max-width: 640px) 100vw, 66vw'); ?> <span class="article-card-tag"><?php echo htmlspecialchars($cat_info['name']); ?></span> </div> </a> <div class="article-featured-body"> <h2><a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($featured['filename']); ?>"><?php echo htmlspecialchars($featured['title']); ?></a></h2> <?php if (!empty($featured['intro'])): ?> <p><?php echo htmlspecialchars(mb_substr($featured['intro'], 0, 250)); ?>...</p> <?php endif; ?> <div class="article-card-meta"> <?php if (!empty($featured['date'])): ?> <span><?php echo htmlspecialchars($featured['date']); ?></span> <?php endif; ?> <span class="article-card-read"><?php echo htmlspecialchars($featured['read_time'] ?? '5'); ?> <?php echo $lang['read_time'] ?? 'min de lecture'; ?> →</span> </div> </div> </article> <?php if (!empty($rest)): ?> <div class="articles-grid"> <?php foreach ($rest as $article): ?> <article class="article-card"> <a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"> <div class="article-card-image"> <?php picture($article['image'], $article['title'], '(max-width: 640px) 100vw, (max-width: 968px) 50vw, 33vw'); ?> <span class="article-card-tag"><?php echo htmlspecialchars($cat_info['name']); ?></span> </div> </a> <div class="article-card-body"> <h2><a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"><?php echo htmlspecialchars($article['title']); ?></a></h2> <?php if (!empty($article['intro'])): ?> <p><?php echo htmlspecialchars(mb_substr($article['intro'], 0, 150)); ?>...</p> <?php endif; ?> <div class="article-card-meta"> <?php if (!empty($article['date'])): ?> <span><?php echo htmlspecialchars($article['date']); ?></span> <?php endif; ?> <span class="article-card-read"><?php echo htmlspecialchars($article['read_time'] ?? '5'); ?> <?php echo $lang['read_time'] ?? 'min de lecture'; ?> →</span> </div> </div> </article> <?php endforeach; ?> </div> <?php endif; ?> <?php endif; ?> </section> <?php elseif ($category_style === 'list'): ?> <section class="category-hero-compact"> <div class="breadcrumb"><a href="/"><?php echo $lang['home'] ?? 'Accueil'; ?></a> › <?php echo htmlspecialchars($cat_info['name']); ?></div> <h1><?php echo htmlspecialchars($cat_info['name']); ?></h1> <p><?php echo htmlspecialchars($cat_info['description']); ?></p> </section> <section class="articles-section"> <?php if (empty($articles)): ?> <div class="empty-state"> <div class="empty-state-icon"><?php echo $cat_info['icon']; ?></div> <h2> </h2> <p> </p> </div> <?php else: ?> <div class="articles-list"> <?php foreach ($articles as $article): ?> <article class="article-row"> <a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>" class="article-row-image"> <?php picture($article['image'], $article['title'], '(max-width: 640px) 100vw, 300px'); ?> </a> <div class="article-row-body"> <span class="article-card-tag"><?php echo htmlspecialchars($cat_info['name']); ?></span> <h2><a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"><?php echo htmlspecialchars($article['title']); ?></a></h2> <?php if (!empty($article['intro'])): ?> <p><?php echo htmlspecialchars(mb_substr($article['intro'], 0, 200)); ?>...</p> <?php endif; ?> <div class="article-card-meta"> <?php if (!empty($article['date'])): ?> <span><?php echo htmlspecialchars($article['date']); ?></span> <?php endif; ?> <span class="article-card-read"><?php echo htmlspecialchars($article['read_time'] ?? '5'); ?> <?php echo $lang['read_time'] ?? 'min de lecture'; ?> →</span> </div> </div> </article> <?php endforeach; ?> </div> <?php endif; ?> </section> <?php elseif ($category_style === 'minimal'): ?> <section class="category-header-minimal"> <div class="breadcrumb"><a href="/"><?php echo $lang['home'] ?? 'Accueil'; ?></a> › <?php echo htmlspecialchars($cat_info['name']); ?></div> <h1><?php echo htmlspecialchars($cat_info['name']); ?></h1> </section> <section class="articles-section"> <?php if (empty($articles)): ?> <div class="empty-state"> <div class="empty-state-icon"><?php echo $cat_info['icon']; ?></div> <h2> </h2> <p> </p> </div> <?php else: ?> <div class="articles-grid-compact"> <?php foreach ($articles as $article): ?> <article class="article-card-compact"> <a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"> <div class="article-card-image"> <?php picture($article['image'], $article['title'], '(max-width: 640px) 50vw, 25vw'); ?> </div> </a> <div class="article-card-body"> <h2><a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"><?php echo htmlspecialchars($article['title']); ?></a></h2> <div class="article-card-meta"> <?php if (!empty($article['date'])): ?> <span><?php echo htmlspecialchars($article['date']); ?></span> <?php endif; ?> <span class="article-card-read"><?php echo htmlspecialchars($article['read_time'] ?? '5'); ?> min</span> </div> </div> </article> <?php endforeach; ?> </div> <?php endif; ?> </section> <?php elseif ($category_style === 'banner'): ?> <section class="category-banner-hero"> <?php $banner_image = $cat_info['banner_image'] ?? ($cat_info['image'] ?? ''); if ($banner_image): ?> <?php picture($banner_image, $cat_info['name'], '100vw', '', 'eager'); ?> <?php endif; ?> <div class="category-banner-overlay"> <div class="breadcrumb"><a href="/"><?php echo $lang['home'] ?? 'Accueil'; ?></a> › <?php echo htmlspecialchars($cat_info['name']); ?></div> <h1><?php echo htmlspecialchars($cat_info['name']); ?></h1> <p><?php echo htmlspecialchars($cat_info['description']); ?></p> </div> </section> <section class="articles-section"> <?php if (empty($articles)): ?> <div class="empty-state"> <div class="empty-state-icon"><?php echo $cat_info['icon']; ?></div> <h2> </h2> <p> </p> </div> <?php else: ?> <div class="articles-grid"> <?php foreach ($articles as $article): ?> <article class="article-card"> <a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"> <div class="article-card-image"> <?php picture($article['image'], $article['title'], '(max-width: 640px) 100vw, (max-width: 968px) 50vw, 33vw'); ?> <span class="article-card-tag"><?php echo htmlspecialchars($cat_info['name']); ?></span> </div> </a> <div class="article-card-body"> <h2><a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"><?php echo htmlspecialchars($article['title']); ?></a></h2> <?php if (!empty($article['intro'])): ?> <p><?php echo htmlspecialchars(mb_substr($article['intro'], 0, 150)); ?>...</p> <?php endif; ?> <div class="article-card-meta"> <?php if (!empty($article['date'])): ?> <span><?php echo htmlspecialchars($article['date']); ?></span> <?php endif; ?> <span class="article-card-read"><?php echo htmlspecialchars($article['read_time'] ?? '5'); ?> <?php echo $lang['read_time'] ?? 'min de lecture'; ?> →</span> </div> </div> </article> <?php endforeach; ?> </div> <?php endif; ?> </section> <?php elseif ($category_style === 'cards_horizontal'): ?> <section class="category-hero"> <div class="category-hero-inner"> <div class="breadcrumb"><a href="/"><?php echo $lang['home'] ?? 'Accueil'; ?></a> › <?php echo htmlspecialchars($cat_info['name']); ?></div> <div class="category-icon"><?php echo $cat_info['icon']; ?></div> <h1><?php echo htmlspecialchars($cat_info['name']); ?></h1> <p><?php echo htmlspecialchars($cat_info['description']); ?></p> </div> </section> <section class="articles-section"> <?php if (empty($articles)): ?> <div class="empty-state"> <div class="empty-state-icon"><?php echo $cat_info['icon']; ?></div> <h2> </h2> <p> </p> </div> <?php else: ?> <div class="articles-list-horizontal"> <?php foreach ($articles as $article): ?> <article class="article-card-horizontal"> <a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>" class="article-card-horizontal-image"> <?php picture($article['image'], $article['title'], '(max-width: 640px) 100vw, 400px'); ?> <span class="article-card-tag"><?php echo htmlspecialchars($cat_info['name']); ?></span> </a> <div class="article-card-body"> <h2><a href="/<?php echo $category; ?>/<?php echo htmlspecialchars($article['filename']); ?>"><?php echo htmlspecialchars($article['title']); ?></a></h2> <?php if (!empty($article['intro'])): ?> <p><?php echo htmlspecialchars(mb_substr($article['intro'], 0, 200)); ?>...</p> <?php endif; ?> <div class="article-card-meta"> <?php if (!empty($article['date'])): ?> <span><?php echo htmlspecialchars($article['date']); ?></span> <?php endif; ?> <span class="article-card-read"><?php echo htmlspecialchars($article['read_time'] ?? '5'); ?> <?php echo $lang['read_time'] ?? 'min de lecture'; ?> →</span> </div> </div> </article> <?php endforeach; ?> </div> <?php endif; ?> </section> <?php endif; ?> </div> <?php include __DIR__ . '/parts/footer.php'; ?>