Enhance the <title> Tag, if you are a SEO-Maniac

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Enhance the <title> Tag, if you are a SEO-Maniac

Post by marcus@localhorst »

Hi,
I've wrote a little - very simple RT, to overwrite/enhance the Title Tag.
You know, TITLE tags are important and they are taken internally from the article Headline. That is not always enough, if you can't place Keywords in the headline, without it looks ugly.
So I've wrote that few lines ov code, to overwrite the article headline.
maybe it is useful for you?!

Put this lines of Code into the frontend_render and add to your Articles (in the Head) the following line
[TITLE]my new Articletitle with some SEO Keywords, but don't overstate this[/TITLE]

The script find the Tag, extract the Text and add it to the titletag (you need to change the script a bit) - due the fact, that you write the [TITLE] tag in the Body, the script <!--comment--> it out, so it is only shown in the sourcecode.

Code: Select all

/*******************************************************************************
  [TITLE]
  überschreibt den pagetitle <title>
  12-Jun-2006
*******************************************************************************/

if( ! (strpos($content["all"],'[TITLE')===false)) {
preg_match('/\[TITLE\](.*?)\[\/TITLE\]/', $content["all"], $match);
$content["pagetitle"] = "Your Title | ".$content["struct"][$content["cat_id"]]["acat_name"]." | ".preg_replace('/\[TITLE\](.*?)\[\/TITLE\]/', '$1', $match[0]);
$content["all"]	= preg_replace('/\[TITLE\](.*?)\[\/TITLE\]/', '<!--$1-->', $content["all"]);
}
simple solution, if you have questions, ask.
best
marcus
Post Reply