Skip to content
Snippets Groups Projects
Verified Commit 59811c1d authored by David Beniamine's avatar David Beniamine
Browse files

Better category handling

Fix #3
parent 02dea9de
Branches
No related tags found
No related merge requests found
<?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>
<h2> Dernier article </h2>
<?php include("single_article.php"); ?>
</li>
<li style="background:none">
<h1> Catégories d'articles </h1>
<?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 / posts_per_page()) * 20))); ?>
<?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>
</li>
<?php endif; ?>
<?php endwhile; ?>
</li>
<?php endif; ?>
<?php if(total_posts() > 1 || $title=="Blog"):?>
<li style="background:none">
<h1> Articles précédents </h1>
<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>
</li>
<?php endwhile; ?>
</li>
<?php endif?>
</ul>
<?php if(has_pagination()): ?>
......
......@@ -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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment