SPIP : afficher directement un article quand c'est le seul de la rubrique
Par fpl le mercredi 18 juin 2008, 15:22 - Général - Lien permanent
A insérer au début du squelette de la rubrique :
#CACHE{0}
<BOUCLE_rubrique_principal(RUBRIQUES) {id_rubrique}>
<?php
$nb_art=<BOUCLE_nb_articles(ARTICLES){id_rubrique}></BOUCLE_nb_articles>#TOTAL_BOUCLE ;
if ($nb_art == 1) {
# SI 1 SEUL ARTICLE, ON Y VA DIRECT !
header("Location: <BOUCLE_article_seul(ARTICLES){id_rubrique}>#URL_ARTICLE</BOUCLE_article_seul>");
exit(0);
}
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>




Commentaires
Petite correction :
#CACHE{0}<BOUCLE_rubrique_principal(RUBRIQUES) {id_rubrique}>
<?php
$nb_art=<BOUCLE_nb_articles(ARTICLES){id_rubrique}></BOUCLE_nb_articles>#TOTAL_BOUCLE</B_nb_articles>#TOTAL_BOUCLE<//B_nb_articles>;
if ($nb_art == 1) {
# SI 1 SEUL ARTICLE, ON Y VA DIRECT !
header("Location: <BOUCLE_article_seul(ARTICLES){id_rubrique}>#URL_ARTICLE</BOUCLE_article_seul>");
exit(0);
}
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>