Il est possible avec Dotclear et les plugins twMeta et twTags de marquer les billets par des mots clés appelés 'tag'. Le système permet de visualiser l'ensemble des billets marqués d'un tag particulier, ou de naviguer en cliquant dans un 'nuage de tag', le Tagcloud.

D'origine Dotclear permet la génération de flux de syndication au format RSS 1.0. Ces flux peuvent contenir en fonction de l'URL d'appel :

  • les derniers billets du blog
  • les derniers billets d'une catégorie
  • les derniers commentaires du blog
  • les derniers commentaires d'une catégorie
  • les derniers commentaires d'un billet

Pour le quatre premiers flux, il est possible de restreindre la génération aux seules informations disponible dans une langue donnée.

De plus selon une option choisie dans la partie administration, ces flux peuvent contenir les informations complètes, ou tronquées.

Comme l'a fait remarquer Empyrée, il n'est pas possible de générer des flux relatif à un tag. J'ai donc modifié le script produisant ces flux pour permettre la génération de flux par tag. Le flux dans ce cas, ne contient que les billets marqués d'un certain tag.

Le fichier s'appelle rss.php , et il est normalement situé dans le répertoire d'installation de Dotclear. Les modifications sont simples : récupération du paramètre $tag, chargement du plugin twMeta, appel de la fonction listant les billet par tag de ce plugin. La suite des traitement est inchangée, exploitation de la liste générée pour produire un flux RSS valide.

[php]

# ***** BEGIN LICENSE BLOCK *****
# This file is part of DotClear.
# Copyright (c) 2004 Olivier Meunier and contributors. All rights
# reserved.
#
# DotClear is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# DotClear is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DotClear; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ***** END LICENSE BLOCK *****
$app_path = '/';
require dirname(__FILE__).$app_path.'inc/prepend.php';
require dirname(__FILE__).$app_path.'layout/lib.cache.php';

require dirname(__FILE__).$app_path.'layout/class.xblog.php';
require dirname(__FILE__).$app_path.'layout/class.xblogpost.php';
require dirname(__FILE__).$app_path.'layout/class.xblogcomment.php';

if (file_exists(dirname(__FILE__).$app_path.DC_ECRIRE.'/tools/twpostmeta/functions.php')) {
require dirname(__FILE__).$app_path.DC_ECRIRE.'/tools/twpostmeta/functions.php';
$meta_plug = true;
} else {
$meta_plug = false;
}

//JL 2006-02 add RSS/tag
//$type = (!empty($_GET['type']) && $_GET['type'] == 'co') ? 'co' : 'blog';
$type = (!empty($_GET['type']) && ($_GET['type'] == 'co' or $_GET['type'] == 'tag')) ? $_GET['type'] : 'blog';
//$type = (!empty($_GET['type'])) ? $_GET['type'] : 'blog';
$tag = (!empty($_GET['tag'])) ? $_GET['tag'] : '';

$cat = (!empty($_GET['cat'])) ? $_GET['cat'] : '';
$lang = (!empty($_GET['lang'])) ? $_GET['lang'] : '';

# Connexion MySQL
$con = new Connection(DB_USER,DB_PASS,DB_HOST,DB_DBASE);

if ($con->error()) { exit; }

# Création de l'objet de type weblog avec uniquement les billets
# publiés
$blog = new xblog($con,DB_PREFIX,1,dc_encoding);
$blog->rs_blogpost = 'xblogpost';
$blog->rs_blogcomment = 'xblogcomment';

$blog->setURL('post','http://'.$_SERVER['HTTP_HOST'].dc_blog_url.dc_format_post_url);

# Si type = co on fait un fil des commentaires
if ($type == 'co')
{
if (!empty($_GET['post'])) {
$comments = $blog->getComments($_GET['post'],'DESC');
} else {
$comments = $blog->getComments('','DESC',20);
}

$title = dc_blog_name.' - Commentaires';
$ts = time();
$items = $seq = '';

if (!$comments->isEmpty())
{
$ts = $comments->getTS();

while(!$comments->EOF())
{
$seq .= $comments->getRSSSeq();
$items .= $comments->getRSSItem(dc_short_feeds);

$comments->moveNext();
}
}
}
else
{
//JL 2006-02 add RSS/tag
# par tag
if ($meta_plug == true && $type == 'tag'){
$news = twPostMeta::getLastNews('tag', $tag, 10, 'post_dt DESC', $lang);
} else {
# Dernières nouvelles
$news = $blog->getLastNews(10,$cat,'post_dt DESC',false,$lang);
}

$ts = strtotime($blog->getEarlierDate());
$title = dc_blog_name;

$items = $seq = '';
while(!$news->EOF())
{
$items .= $news->getRSSItem(dc_short_feeds);
$seq .= $news->getRSSSeq();

$news->moveNext();
}
}

//... la suite inchangée

Vous remarquez que :

  • La génération des flux peut prendre en compte toutes combinaisons des paramètre tag, catégorie et langue.
  • Pour l'instant seul les flux RSS de billet peuvent être générés en sélectionnant un tag.
  • Il n'est toujours pas possible de sélectionner plusieurs catégories ou plusieurs tag pour générer un flux..