Possible General SEF Solution

This forum is for reporting bugs in Joomla!. Please don't report problems with extensions in here.
Locked
User avatar
tcp
Joomla! Ace
Joomla! Ace
Posts: 1548
Joined: Wed Sep 21, 2005 9:25 am
Location: Thailand
Contact:

Possible General SEF Solution

Post by tcp » Sat Dec 08, 2007 10:14 am

Note: Split from http://forum.joomla.org/index.php/topic,235880.0.html .

Attaching a proof-of-concept SEF System Plugin.  This plugin resolves this issue on my system, but again, only a proof-of-concept. 

Do not install this on a production site!
You do not have the required permissions to view the files attached to this post.
Last edited by tcp on Sat Dec 08, 2007 12:58 pm, edited 1 time in total.
Your solution for a single-page checkout on any website.
http://moolah-ecommerce.com

User avatar
masterchief
Joomla! Hero
Joomla! Hero
Posts: 2247
Joined: Fri Aug 12, 2005 2:45 am
Location: Brisbane, Australia
Contact:

Possible General SEF Solution

Post by masterchief » Sat Dec 08, 2007 10:59 am

Personally I'd see this particular function moved to the API I think.  I come across a lot of instances where you need to fix the paths, but don't always want the overhead of running a description field through all the content plugins.  Not sure exactly where is best but something along the lines of:

description ); ?>

The SEF content plugin could actually call this tool so that we aren't duping code??

To test that it would be something like
file = libraries/joomla/html/html/route.php

Code: Select all

class JHTMLRoute
{
function links( $text )
{
//Replace src links
$base = JURI::base(true).'/';
$text = preg_replace("/(src)=\"(?!http|ftp|https)([^\"]*)\"/", "$1=\"$base\$2\"", $text);
	
//Replace href links
$regex = "#href=\"(.*?)\"#s";

// perform the replacement
$text = preg_replace_callback( $regex, 'jhtmlRouteLink_replacer', $text );
}
}

function jhtmlRouteLink_replacer ... same as in the plugin
Someone want to give that a try?
Andrew Eddie - Tweet @AndrewEddie
<><
http://eddify.me
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.

User avatar
tcp
Joomla! Ace
Joomla! Ace
Posts: 1548
Joined: Wed Sep 21, 2005 9:25 am
Location: Thailand
Contact:

Possible General SEF Solution

Post by tcp » Sat Dec 08, 2007 12:42 pm

Well, don't worry, I'm trying not to get carried away here, but what about something like this.

An API call would be neat, but I'm still interested in something that could work even more generically.  Since JDocument calls various render functions maybe this would be a good place to put some code that parses the output.  I'd still like to see this implemented as an event based plugin, but at this stage of the game maybe that isn't wise.  That being said, we've been dealing with SEF problems for a long, long time now.

System Plugin

Code: Select all

function onAfterRenderComponent($body)
	{
		//Replace src links
		$base = JURI::base(true).'/';

		//$body = JResponse::getBody();
		$body = preg_replace('#(src)="(?!http|ftp|https|/)([^"]*)"#', "$1=\"$base\$2\"", $body);
		
		//Replace href links
		$proto = 'http:|ftp:|https:|mailto:|data:|file:|ftp:|gopher:|imap:|ldap:|news:|nntp:|telnet:|javascript:|irc:';
		$regex = '#href="((?!/|'.$proto.'))([^"]*?)"#m';
		
		$body = preg_replace_callback( $regex, 'plgContentSEF_replacer', $body );
	
		//JResponse::setBody($body);
	}
Then this code in JComponentHelper::renderComponent() .

Code: Select all

{
		... // lots of code above here
		
		JApplication::triggerEvent('onAfterRenderComponent', array(&$contents) );

		return $contents;
	}
Ideally we would do this under the caching layer. For modules, the caching layer starts in JDocumentRendererModule, so we could implement something like this in JModuleHelper::renderModule().  Components are different - implementation starts in JController::display(). 

Anyways, at this point I'm just throwing ideas around.
Last edited by tcp on Sat Dec 08, 2007 12:57 pm, edited 1 time in total.
Your solution for a single-page checkout on any website.
http://moolah-ecommerce.com

User avatar
ircmaxell
Joomla! Ace
Joomla! Ace
Posts: 1926
Joined: Thu Nov 10, 2005 3:10 am
Location: New Jersey, USA
Contact:

Re: Possible General SEF Solution

Post by ircmaxell » Mon Dec 10, 2007 7:05 pm

If we add it to the framework (such as MasterChief sugested), we could hard code to the pre-caching layer of components and modules the call (no need for a plugin and the overhead it adds)...
Anthony Ferrara - Core Team - Development Coordinator - Bug Squad - JSST

http://moovum.com/ - The Bird is in the air! Get Mollom Anti-Spam on your Joomla! website with Moovur...
http://www.joomlaperformance.com For All Your Joomla Performance Needs


Locked

Return to “Joomla! 1.5 Bug Reporting”