diff --git a/posts.php b/posts.php index 414ed21458403568f688432d15f442e5afcf760f..914382ba0ce759c5287c048ded6e7588a3910a3d 100644 --- a/posts.php +++ b/posts.php @@ -1,32 +1,53 @@ <?php theme_include('header'); ?> <section class="content"> - + <?php + $title="Blog"; + if (preg_match('/category.*/',current_url())){ + echo "<p id='".current_url()."'></p>"; + while(categories()){ + echo "<p id='".category_url()."'></p>"; + if(category_url() == "/".current_url()){ + $title.=" - ".category_title(); + } + } + } + echo "<h1 style='text-align:center'>$title</h1>\n"; + ?> <?php if(has_posts()): ?> <ul class="items"> <?php posts(); ?> <li> - <h1> Dernier article </h1> - <?php include("single_article.php"); ?> - </li> - <li style="background:none"> - <h1> Catégories d'articles </h1> - <?php $i = 0; while(categories()): ?> - <?php $bg = sprintf('background: hsl(131, 6%%, %d%%);', round(50-((++$i / posts_per_page()) * 20))); ?> - <li style="<?php echo $bg; ?>"> - <?php include("single_category.php"); ?> - </li> - </li> - <?php endwhile; ?> - <li style="background:none"> - <h1> Articles précédents </h1> - <?php $i = 0; while(posts()): ?> - <?php $bg = sprintf('background: hsl(131, 6%%, %d%%);', round(50-((++$i / posts_per_page()) * 20))); ?> - <li style="<?php echo $bg; ?>"> + <h2> Dernier article </h2> <?php include("single_article.php"); ?> </li> - </li> - <?php endwhile; ?> + + <?php if (!preg_match('/category.*/',current_url())): ?> + <li id="<?php echo current_url();?>" style="background:none"> + <h2> Catégories d'articles </h2> + <?php $i = 0; while(categories()): ?> + <?php $bg = sprintf('background: hsl(131, 6%%, %d%%);', round(50-(($i / total_categories()) * 20))); ?> + <?php if(category_count() > 0 ):?> + <?php ++$i; ?> + <li style="<?php echo $bg; ?>"> + <?php include("single_category.php"); ?> + </li> + <?php endif; ?> + <?php endwhile; ?> + </li> + <?php endif; ?> + + <?php if(total_posts() > 1 || $title=="Blog"):?> + <li style="background:none"> + <h2> Articles précédents </h2> + <?php $i = 0; while(posts()): ?> + <?php $bg = sprintf('background: hsl(131, 6%%, %d%%);', round(50-((++$i / posts_per_page()) * 20))); ?> + <li style="<?php echo $bg; ?>"> + <?php include("single_article.php"); ?> + </li> + <?php endwhile; ?> + </li> + <?php endif?> </ul> <?php if(has_pagination()): ?> diff --git a/single_category.php b/single_category.php index 3d39ad52f9a65ab9b72e812d946b4f58a28b455b..cc2c9740ce8c869966ef9dcd743944aca2a5ead3 100644 --- a/single_category.php +++ b/single_category.php @@ -7,4 +7,9 @@ <div class="contents"> <?php echo category_description(); ?> </div> + <footer> + <p> + Cette catégorie regroupe <?php echo category_count(); ?> <?php echo pluralise(category_count(), "article", "s")?>. + </p> + </footer> </article>