Voici une proposition pour un fichier sitemap enrichi.
Pour cela, il faut créer un fichier sitemap.xml.html dans le répertoire /squelettes pour surcharger le fichier sitemap par défaut. Je n’ai pas pris en compte les brèves dans ma solution car je ne les utilise pas, mais cela ne doit pas être compliqué de les réintégrer :
#CACHE{0}
#HTTP_HEADER{Content-Type: text/xml; charset=utf-8}
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>[(#URL_SITE_SPIP)]</loc>
<BOUCLE_maj(ARTICLES){tout}{par date_modif}{inverse}{0,1}>[(#DATE_MODIF|?{[ <lastmod>(#DATE_MODIF|date_iso)</lastmod>]})]</BOUCLE_maj>
<changefreq>hourly</changefreq>
<priority>1.0</priority>
</url>
<BOUCLE_r(RUBRIQUES){!par date}{0,1000}>
<url>
<loc>[(#URL_RUBRIQUE|url_absolue)]</loc>
<lastmod>[(#DATE|date_iso)]</lastmod>
<changefreq>daily</changefreq>
<priority>0.6</priority>
</url>
</BOUCLE_r>
<BOUCLE_a(ARTICLES){!par date_modif}{!par date}{0,2000}>
<url>
<loc>[(#URL_ARTICLE|url_absolue)]</loc>
<lastmod>[(#DATE_MODIF|date_iso)]</lastmod>
<changefreq>weekly</changefreq>
<priority>[(#POPULARITE|pourcent)]</priority>[
<image:image>
<image:loc>#URL_SITE_SPIP/(#LOGO_ARTICLE_RUBRIQUE||url_de_logo|remove_param)</image:loc>
<image:title>[(#TITRE|textebrut|add_cdata)]</image:title>
<image:caption>[(#TITRE|textebrut|add_cdata)]</image:caption>
</image:image>]<BOUCLE_mesimages(DOCUMENTS){id_article}{mode=image}{doublons}>
<image:image>
<image:loc>[(#URL_DOCUMENT|url_absolue)]</image:loc>[
<image:caption>(#TITRE|textebrut|add_cdata)</image:caption>][
<image:title>(#TITRE|textebrut|add_cdata)</image:title>]
</image:image></BOUCLE_mesimages>
</url>
</BOUCLE_a>
</urlset>
Ce squelette utilise plusieurs fonctions personnalisées. Il faut donc éditer le fichier mes_fonctions.php dans le répertoire /squelettes et ajouter, à l’intérieur du bloc php (avant le " ?>" final), le code suivant :
function url_de_logo($texte) {
ereg('src="([^"]*)"', $texte, $regs);
return $regs[1];
}
function add_cdata($texte) {
return "<![CDATA[".$texte."]]>";
}
function remove_param($texte) {
if ( $nb = strrpos( $texte, "?" ) )
return substr( $texte, 0, $nb );
else
return $texte;
}
function pourcent($valeur) {
return $valeur / 100;
}
J’ai écrit un article plus complet avec des explications détaillées sur la génération de sitemap avec images pour SPIP. L’article précise notamment comment joindre une feuille de style au fichier sitemap pour faciliter la visualisation.
Pour voir le résultat obtenu :
http://www.orsal.fr/sitemap.xml
A+
Guillaume