Insérer le tag CrawlTrack dans DotClear 2
Par cobra le dimanche, octobre 28 2007, 05:19 - DotClear - Lien permanent
Dans DotClear 1, les tags CrawlTrack s'inséraient aisément dans le template, car ce dernier était en PHP.
Avec DotClear 2, c'est chose moins facile, car il est devenu impossible d'insérer du PHP dans le template.... enfin presque.
Dans le dossier themes/default se trouve un fichier _pulic.php qui est exécuté par DotClear 2 lors de chaque affichage.
C'est dans ce fichier que le marqueur va être inséré.
Voici le contenu original de _public.php:
<?php # ***** BEGIN LICENSE BLOCK ***** # This file is part of DotClear. # Copyright (c) 2003-2006 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 *****
$core->tpl->addValue('CustomCSS',array('tplCustomTheme','CustomCSS'));
class tplCustomTheme
{
public static function CustomCSS($attr)
{
$f = $GLOBALS'core'->tpl->getFilters($attr);
return '<?php echo '.sprintf($f,'$core->blog->settings->public_url."/custom_style.css"').'; ?>';
}
}
?>
Le tag sera inséré à l'avant dernière ligne, la ligne précédent: ?> , pour obtenir:
<?php # ***** BEGIN LICENSE BLOCK ***** # This file is part of DotClear. # Copyright (c) 2003-2006 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 *****
$core->tpl->addValue('CustomCSS',array('tplCustomTheme','CustomCSS'));
class tplCustomTheme
{
public static function CustomCSS($attr)
{
$f = $GLOBALS'core'->tpl->getFilters($attr);
return '<?php echo '.sprintf($f,'$core->blog->settings->public_url."/custom_style.css"').'; ?>';
}
}
$crawltsite=1;
require_once("/chemin/vers/le/repertoire/crawltrack.php");
?>
L'exemple montre l'insertion du tag utilisé quand le site est hébergé sur le même serveur que CrawlTrack, si tel n'en était pas le cas, il suffira de le remplacer à l'identique par celui prévu pour un site à distance.
Recopiez (/écrasez) ce fichier dans tous vos thèmes et pensez à le faire au fur et à mesure des rajouts de nouveaux thèmes.
Commentaires