I'm working with the Joomla! CMS and I'm trying to write a simple SEO script which converts keywords to links. It's easy enough, but I'm having an issue with it.
I have GeSHi highlighting throughout my articles using the Joomla! GeSHi library, and sometimes the highlighted code gets ruined with a big juicy [FONT="Courier New"]href [/FONT]because a keyword appears inside the [FONT="Courier New"]<pre xml:lang=""></pre>[/FONT] tags.
So basically, in Joomla! you've got [FONT="Courier New"]$this->item->text[/FONT], which is the full article text. I'm using this code for my SEO:
keywords.php (included in Joomla! core file)
$seo_keywords = array
"PHP" => "http://www.php.net",
"CSS" = > "http://www.w3.org"
$limit = 1; // Limit how many keywords can become links.
foreach($seo_keywords as $key=>$value)
// preg_replace(text to replace, replacement value, subject, limit)
preg_replace("/\b" . $key. "\b/i",
"<a href='" . $value . "'>" . $key . "</a>",
I would like this regular expression to be identical to what it is now, but to ignore all text that appears between <pre xml:lang="some_language"> and </pre>.
Can anyone help me out with the necessary expression?
1. I know there are Joomla! extensions that do auto-SEO, but the reason I decided to write my own code is because those extensions also replace unwanted segments of text with links.
2. These are not my actual keywords.