AGOW_CMS 1.0
Keywords dinamiche
Avendo la possibilita' di cambiare le metatag di ogni pagina dinamicamente, ovvero leggendo realmente il testo della pagina ed estraendone le parole chiave si potrebbero ottenere ottimi risultati sui motori di ricerca.
Ovviamente fare questo non e' cosa semplice e noi non siamo certo così bravi da poterlo fare.
Tuttavia una funzioncina che estrae qualcosa e' stata fatta ... :P
function extract_keywords($text,$qty=250){
$text = strip_tags($text);
$text = unhtmlentities($text);
$v = (double)implode('.',array_slice(explode('.',phpversion()),0,2));
if($v>=5.1)
$wordfrequency = array_count_values(str_word_count($text,1,'àáãçèéùòì'));
else
$wordfrequency = array_count_values(str_word_count($text,1));
arsort($wordfrequency);
foreach($wordfrequency as $word=>$frequency){
if(strlen($word)<4) unset($wordfrequency[$word]);
}
$keywords = array_slice(array_keys($wordfrequency), 0, $qty);
// die('<pre>'.print_r($keywords,1).'</pre>');
$strKeys = implode(', ', $keywords);
return $strKeys;
}
function unhtmlentities ($string) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES, ENT_QUOTES);
$trans_tbl = array_flip ($trans_tbl);
return strtr($string ,$trans_tbl);
}
Con questa funzione si possono estrarre le prime X parole piu' lunghe di 4 caratteri ordinate per frequenza discendente (strippando il codice html ovviamente).
:P
Autore: #ffffff (09-02-2007 00:00:00)
07-01-2009 - PM 02:30