Phorum data in meta description and title
Posted by Brian Moon
|
Phorum data in meta description and title September 24, 2005 07:03AM |
Admin Registered: 25 years ago Posts: 4,506 |
Update: The code was messing up titles on pages that used the message template.
I have added a little text to my headers here at phorum.org to optimize the title and meta description tag in Phorum. While I can't say it helped Google, search results for our site look better on Google for sure. We had the same meta on all pages before. Not sure if this will help on a page that has no meta tags or not.
See: [www.google.com] for how it looks in Google with this in use on read pages.
Edited 4 time(s). Last edit at 03/01/2006 05:40PM by brianlmoon.
I have added a little text to my headers here at phorum.org to optimize the title and meta description tag in Phorum. While I can't say it helped Google, search results for our site look better on Google for sure. We had the same meta on all pages before. Not sure if this will help on a page that has no meta tags or not.
<?php
// defaults for all Phorum pages
$TITLE = $PHORUM["DATA"]["HTML_TITLE"];
$DESCRIPTION = "Your page default meta description 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))));
} 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?>" />
See: [www.google.com] for how it looks in Google with this in use on read pages.
Brian - Personal Blog
Edited 4 time(s). Last edit at 03/01/2006 05:40PM by brianlmoon.
|
Re: Phorum data in meta description and title September 24, 2005 04:10PM |
Registered: 21 years ago Posts: 609 |
Is it suppose to strip everything in message body even the spaces between words?
It works but in the description the message body are completely stripped including the spaces between the words ..
Example.
In Message body:
It is printed in bold white letters on a Royal Blue background with the "State of Louisiana" seal in gold.
In Meta Description:
ItisprintedinboldwhitelettersonaRoyalBluebackgroundwiththe"StateofLouisiana"sealingold
Thanks
Bill
It works but in the description the message body are completely stripped including the spaces between the words ..
Example.
In Message body:
It is printed in bold white letters on a Royal Blue background with the "State of Louisiana" seal in gold.
In Meta Description:
ItisprintedinboldwhitelettersonaRoyalBluebackgroundwiththe"StateofLouisiana"sealingold
Thanks
Bill
|
Re: Phorum data in meta description and title September 24, 2005 06:08PM |
Admin Registered: 22 years ago Posts: 8,532 |
|
Re: Phorum data in meta description and title September 24, 2005 06:09PM |
Registered: 21 years ago Posts: 609 |
|
Re: Phorum data in meta description and title September 25, 2005 09:24PM |
Admin Registered: 25 years ago Posts: 4,506 |
I changed the original post. Sorry about that. It was not an exact copy and paste from my code as mine is in my site header, not the template header.
Brian - Personal Blog
|
Re: Phorum data in meta description and title October 06, 2005 01:34PM |
Registered: 21 years ago Posts: 609 |
I allows smileys on my forum subject line so any time anyone use a smiley in the sujbect line it would show the actual smileys html tags in the title so here my version of the php meta tag which is same as Brain but changed slightly to strip the html codes from the title.
--change--
// title and meta for read pages
$TITLE = htmlspecialchars($PHORUM["DATA"]["MESSAGE"]["subject"]);
--to--
// title and meta for read pages
$TITLE = htmlspecialchars(preg_replace('!\s+!s', " ", strip_tags($PHORUM["DATA"]["MESSAGE"]["subject"])));
--change--
// title and meta for list pages
$TITLE = $PHORUM["name"];
--to--
// title and meta for list pages
$TITLE = preg_replace('!\s+!s', " ", strip_tags($PHORUM["name"]));
Bill
--change--
// title and meta for read pages
$TITLE = htmlspecialchars($PHORUM["DATA"]["MESSAGE"]["subject"]);
--to--
// title and meta for read pages
$TITLE = htmlspecialchars(preg_replace('!\s+!s', " ", strip_tags($PHORUM["DATA"]["MESSAGE"]["subject"])));
--change--
// title and meta for list pages
$TITLE = $PHORUM["name"];
--to--
// title and meta for list pages
$TITLE = preg_replace('!\s+!s', " ", strip_tags($PHORUM["name"]));
Bill
|
Re: Phorum data in meta description and title November 25, 2005 07:11AM |
Registered: 23 years ago Posts: 687 |
I don't think it is advisable to have some pages contain large (1000s of characters) meta descriptions, which unless I am missing something the code above will allow. Even avoiding getting into a SEO debate, it is still IMHO a waste of bandwidth.
I'd suggest something like:
This will truncate your page description to 500 characters - chop and change based on your SEO preferences.
/\dam
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
I'd suggest something like:
$DESCRIPTION = htmlspecialchars(preg_replace('!\s+!s'," ",strip_tags(substr($PHORUM["DATA"]["MESSAGE"]["body"],0,500))));
This will truncate your page description to 500 characters - chop and change based on your SEO preferences.
/\dam
--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
|
Re: Phorum data in meta description and title December 20, 2005 10:10AM |
Registered: 21 years ago Posts: 135 |
Quote
sheik
I don't think it is advisable to have some pages contain large (1000s of characters) meta descriptions, which unless I am missing something the code above will allow. Even avoiding getting into a SEO debate, it is still IMHO a waste of bandwidth.
I'd suggest something like:
$DESCRIPTION = htmlspecialchars(preg_replace('!\s+!s'," ",strip_tags(substr($PHORUM["DATA"]["MESSAGE"]["body"],0,500))));
This will truncate your page description to 500 characters - chop and change based on your SEO preferences.
/\dam
This is exact the same what I also thought about it. 200 letters should be maximum.
If you look in the HTML-Source of Brian's first posting [phorum.org] , you also see how much (too much) text there is.
bye
irob
|
Re: Phorum data in meta description and title December 20, 2005 11:43AM |
Admin Registered: 25 years ago Posts: 4,506 |
|
Re: Phorum data in meta description and title December 21, 2005 06:12AM |
Registered: 21 years ago Posts: 135 |
hi,
What exactly must I write, if I want the "cut" text after a [ENTER]-sign (<br>) instead of a cut after 500 letters? Thank you.
bye,
irob
Quote
sheik
$DESCRIPTION = htmlspecialchars(preg_replace('!\s+!s'," ",strip_tags(substr($PHORUM["DATA"]["MESSAGE"]["body"],0,500))));
This will truncate your page description to 500 characters - chop and change based on your SEO preferences.
What exactly must I write, if I want the "cut" text after a [ENTER]-sign (<br>) instead of a cut after 500 letters? Thank you.
bye,
irob
Sorry, only registered users may post in this forum.
