Jacek, well what you do is dynamic routing. There is nothing wrong with this, and I think it's good to make as much use of CakePHP's build in support as possible, there are situations where this solution won't quit do it.

For example, at the moment it is impossible to route to plugin controllers, it's also not possible to do language url's like: /{lang}/controller/action with the normal routing class. For that reason I think what you really want is dynamic url rewriting. I think this could be done by a singleton UrlRewrite class that would then be extended into a AppUrlRewrite class where you can manually parse / rewrite and analyze all urls.

I might code something like this at some point, I'll let you know if I do.

Best Regards,
Felix Geisendörfer


Jacek schrieb:
I wrote this

uses('Sanitize');
$dbconf=new DATABASE_CONFIG();
[EMAIL PROTECTED]($dbconf->default['host'],
$dbconf->default['login'], $dbconf->default['password'] );
@mysql_select_db($dbconf->default['database'], $mydb);

$sanit=new Sanitize();
$mylink=$sanit->sql(substr($_SERVER['QUERY_STRING'], 4));
[EMAIL PROTECTED]("select * from friendlylinks where
link='".$mylink."'", $mydb);
if($myres && mysql_numrows($myres)>0){
	$mydata=mysql_fetch_assoc($myres);
	$myroutedata=explode('/', $mydata['action']);
	$routeparams=array();
	$routeparams['controller']=$myroutedata[0];
	$routeparams['action']=$myroutedata[1];
	if(count($myroutedata)>2)
		array_push($routeparams, $myroutedata[2]);
	$Route->connect($mylink, $routeparams);
	mysql_free_result($myres);
}


It's working. What do you think of this?




  

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to