Titre du sujet : Re: Cherche développeur pour amélioration du référencement de CBB par babouille sur 03/11/2005 10:45:20
Voila: http://www.thesiteoueb.net/modules/ne ... php?topic_id=2034&forum=1 faites un clic droit et "source"
J'ai crée un fichier fonction_keyword.php que j'ai mis dans le dossier include
<?
//hack de keyword
function forum_extract_keywords($post_text)
{
$tmp=array();
// Search for the Minimum keyword length
$config_handler =& xoops_gethandler('config');
$xoopsConfigSearch =& $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH);
$limit=$xoopsConfigSearch['keyword_min'];
$myts =& MyTextSanitizer::getInstance();
$post_text = str_replace ("<br />", " ", $post_text);
$post_text= $myts->undoHtmlSpecialChars(strip_tags($post_text));
$post_text=strtolower($post_text);
$post_text = str_replace (" ", " ", $post_text);
$post_text = str_replace ("[quote]", "", $post_text);
$post_text = str_replace ("[/quote]", "", $post_text);
$post_text = str_replace ("t", " ", $post_text);
$post_text = str_replace ("rn", " ", $post_text);
$post_text = str_replace ("r", " ", $post_text);
$post_text = str_replace ("n", " ", $post_text);
$post_text = str_replace (",", " ", $post_text);
$post_text = str_replace (".", " ", $post_text);
$post_text = str_replace (";", "", $post_text);
$post_text = str_replace (":", "", $post_text);
$post_text = str_replace (")", "", $post_text);
$post_text = str_replace ("(", "", $post_text);
$post_text = str_replace ('"', "", $post_text);
$post_text = str_replace ('?', "", $post_text);
$post_text = str_replace ('!', "", $post_text);
$post_text = str_replace ('{', "", $post_text);
$post_text = str_replace ('}', "", $post_text);
$post_text = str_replace ('[', "", $post_text);
$post_text = str_replace (']', "", $post_text);
$post_text = str_replace ('<', "", $post_text);
$post_text = str_replace ('>', "", $post_text);
$post_text = str_replace ("'", " ", $post_text);
$keywords=explode(' ',$post_text);
$keywords=array_unique($keywords);
foreach($keywords as $keyword) {
if(strlen($keyword)>=$limit && !is_numeric($keyword)) {
$tmp[]=$keyword;
}
}
if(count($tmp)>0) {
return implode(',',$tmp);
} else {
$xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER);
return $xoopsConfigMetaFooter['meta_keywords'];
}
}
?>
ensuite dans viewtopic.php voila ce que cela donne. Par contre j'aimerai bien virer les appels de bases, donc si quelqu'un a une idée:
if ( empty($topic_lastread[$topic_id]) ) {
$forumtopic->incrementCounter();
}
$topic_lastread[$topic_id] = time();
newbb_setcookie("LT", $topic_lastread);
//hack de la page title
$topic_title = $myts->htmlSpecialChars($forumdata['topic_title']);
$topic_title = str_replace (" ", " ", $topic_title);
$topic_title = str_replace ("'", "'", $topic_title);
$topic_title = str_replace (",", " ", $topic_title);
$topic_title = str_replace (".", " ", $topic_title);
$topic_title = str_replace (";", "", $topic_title);
$topic_title = str_replace (":", "", $topic_title);
$topic_title = str_replace (")", "", $topic_title);
$topic_title = str_replace ("(", "", $topic_title);
$topic_title = str_replace ('"', "", $topic_title);
$topic_title = str_replace ('?', "", $topic_title);
$topic_title = str_replace ('!', "", $topic_title);
$topic_title = str_replace ('{', "", $topic_title);
$topic_title = str_replace ('}', "", $topic_title);
$topic_title = str_replace ('[', "", $topic_title);
$topic_title = str_replace (']', "", $topic_title);
$topic_title = str_replace ('<', "", $topic_title);
$topic_title = str_replace ('>', "", $topic_title);
//$xoops_pagetitle = $xoopsModule->getVar('name'). ' - ' .$myts->htmlSpecialChars($forumdata['forum_name']). ' - ' .$topic_title;
$xoops_pagetitle = $topic_title. ' - ' .$myts->htmlSpecialChars($forumdata['forum_name']).' - ' .$xoopsModule->getVar('name');
include XOOPS_ROOT_PATH."/header.php";
$xoopsTpl->assign('xoops_module_header', $newbb_module_header);
$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
//fin du hack page title
//hack description et mots cles
$sql = "SELECT post_id FROM ".$xoopsDB->prefix("bb_posts")." WHERE topic_id = '$topic_id' AND pid = 0";
$result5 = $xoopsDB->query($sql);
list($post_id) = $xoopsDB->fetchrow($result5);
$sql = "SELECT post_text FROM ".$xoopsDB->prefix("bb_posts_text")." WHERE post_id = '$post_id'";
$result6 = $xoopsDB->query($sql);
list($post_text) = $xoopsDB->fetchrow($result6);
include_once XOOPS_ROOT_PATH . '/modules/newbb/include/fonction_keyword.php';
$xoopsTpl->assign('xoops_meta_keywords', forum_extract_keywords($post_text));
$xoopsTpl->assign('xoops_meta_description', $topic_title);
// fin du hack description et mots cles
Je suis partis sur le code d'Hervé :banane: mais par contre il y a juste un blême sur les séparations des mots clés avec la virgule qui ne donnes pas un espace derrière.
J'attends de voir si quelqu'un peu améliorer cette modeste manip qui me semble loin d'être parfaite.
au fait ce n'est pas "citation" mais "quote" qu'il prend pour du code xoops dans la fonction.
|