Google Website Optimizer Code and SEF plugin problem

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
novon
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Mon Apr 27, 2009 11:12 pm

Google Website Optimizer Code and SEF plugin problem

Post by novon » Mon Jun 08, 2009 10:40 pm

Hello all,

I am trying to implement some split testing on my site using google's WSO service. I copied all the code into my joomla articles as instructed on google's site and this tutorial.

I am having problems validating the pages though. The tutorial I just mentioned has a note about patching joomla versions previous to 1.5.5 or 1.5.6, I am using 1.5.10. I downloaded the patch mentioned and verified that is indeed included with my version of joomla. The problem is that src definitions are still getting the / inserted by the SEF plugin. I disabled the plugin and the pages validate just fine. The problem is this:

Code: Select all

if(typeof(_gat)!='object')document.write('<sc'+'ript src="/http'+
the code snippet should be:

Code: Select all

if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
The regular expression I believe is causing this is found in /plugins/system/sef.php:

Code: Select all

$protocols = '[a-zA-Z0-9]+:';
$regex     = '#(src|href)="(?!/|'.$protocols.'|\#|\')([^"]*)"#m';
Can anybody that is good with regular expressions offer any assistance? Thanks in advance.

Alex

novon
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Mon Apr 27, 2009 11:12 pm

Re: Google Website Optimizer Code and SEF plugin problem

Post by novon » Tue Jun 09, 2009 12:20 am

I have temporarily solved the problem by adding the following line to plugins/system/sef.php around line 64:

Code: Select all

$protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex     = '#(src|href)="(?!/|'.$protocols.'|\#|\')([^"]*)"#m';
$buffer    = preg_replace($regex, "$1=\"$base\$2\"", $buffer);

//The following line was added as a temporary solution to google's website optimizer not working
$buffer = str_replace( "/html", "html", $buffer );
Obviously this isn't the "correct" way to do this but I'm not sure how to modify the regular expression above in order to not insert that / character. Any input on this would be greatly appreciated.


Locked

Return to “Joomla! 1.5 Coding”