Firefox PHP

hack for stripping meta keywords from posts

Posted by solobrian 
hack for stripping meta keywords from posts
June 15, 2006 10:03PM
I'm currently using the hack to strip the first 200 characters and putting them in the meta description

Is there a hack available to do the same thing except strip the first 10-20 words and add them as meta keywords?



Edited 1 time(s). Last edit at 06/16/2006 12:20AM by solobrian.
pat
Re: hack for stripping meta keywords from posts
June 15, 2006 11:12PM
Hi,

haven't tested it but this slightly changed template-hack originally by brian should do:

<?php

// defaults for all Phorum pages
$TITLE = $PHORUM["DATA"]["HTML_TITLE"];
$DESCRIPTION = "Your page default meta description should go here.";
$KEYWORDS = "Your page default keywords should go here.";

if(isset($PHORUM["DATA"]["MESSAGE"]) && is_array($PHORUM["DATA"]["MESSAGE"])){

    // title and meta for read pages
    $TITLE = htmlspecialchars($PHORUM["DATA"]["MESSAGE"]["subject"]);
    $DESCRIPTION = htmlspecialchars(preg_replace('!\s+!s'," ",strip_tags(substr($PHORUM["DATA"]["MESSAGE"]["body"],0,300))));
    $KEYWORDS = htmlspecialchars(preg_replace('!\s+!s'," ",strip_tags(substr($PHORUM["DATA"]["MESSAGE"]["body"],0,20))));

} elseif(isset($PHORUM["description"]) && phorum_page=="list" && $PHORUM["DATA"]["CURRENTPAGE"]==1){

    // title and meta for list pages
    $TITLE = $PHORUM["name"];
    $DESCRIPTION = htmlspecialchars(preg_replace('!\s+!s', " ", strip_tags($PHORUM["description"])));
}
?>
<title><?=$TITLE?></title>
<meta name="description" content="<?=$DESCRIPTION?>" />
<meta name="keywords" content="<?=$KEYWORDS?>" />
Re: hack for stripping meta keywords from posts
June 16, 2006 12:20AM
thanks that worked. it seems be only only stripping 2 words. is there any way to make it do 10?

Or is that bad for SEO?

The dream hack would be to take 10 random words from the post and use those. But thats probably very complicated.



Edited 1 time(s). Last edit at 06/16/2006 12:22AM by solobrian.
pat
Re: hack for stripping meta keywords from posts
June 16, 2006 10:13AM
Hi,

it is taking 20 charakters change it to your liking:

["body"],0,20))));
Sorry, only registered users may post in this forum.

Click here to login