Doing Meta keywords with Freetag
Posted: Sun Apr 16, 2006 3:01 pm
For those who want Meta Keywords:
If you are using Freetag Plugin, you can have set Freetag tags as Meta Keywords in your HTML header by modifying serendipity_event_freetag.php.
Register Freetag for event frontend_header, and add the follwing code to switch($event) in function event_hook:
Now your entry detail pages will show up to $max_keywords tags in your meta keywords, ordered by the most used ones in your blog descending.
All other pages will use the $max_keywords most used tags of your blog, also in descending order.
I hope this feature can be integrated into future versions of Freetag, by setting the $max_keywords in the plugin's options (and using 0 for not displaying) or something like that.
Regards,
Markus
If you are using Freetag Plugin, you can have set Freetag tags as Meta Keywords in your HTML header by modifying serendipity_event_freetag.php.
Register Freetag for event frontend_header, and add the follwing code to switch($event) in function event_hook:
Code: Select all
case 'frontend_header':
$max_keywords = 20;
if (is_int($serendipity['GET']['id'])) {
// select tags from entry $id ordered by most usage descending
$query = "SELECT one.tag, two.entryid, count(two.tag) AS total FROM serendipity_entrytags AS one JOIN serendipity_entrytags AS two ON two.entryid = {$serendipity['GET']['id']} AND one.tag = two.tag GROUP BY one.tag ORDER BY total DESC LIMIT $max_keywords";
} else {
// select most used tags in descending order
$query = "SELECT tag, count(tag) AS total FROM {$serendipity['dbPrefix']}entrytags GROUP BY tag ORDER BY total DESC LIMIT $max_keywords";
}
$rows = serendipity_db_query($query);
if (!is_array($rows)) {
return;
}
echo "<meta description=\"Keywords\" content=\"";
foreach($rows AS $r) {
if (empty($r['tag'])) {
continue;
}
$not_first ? print(', ') : $not_first = true;
echo $r['tag'];
}
echo "\">";
return true;
break;
All other pages will use the $max_keywords most used tags of your blog, also in descending order.
I hope this feature can be integrated into future versions of Freetag, by setting the $max_keywords in the plugin's options (and using 0 for not displaying) or something like that.
Regards,
Markus