How to create routes for component actions?

Notice: This thread is very old.
MartyIX
Member | 217
+
0
-

I have a URL: http://<presenter>.<domainName>.<tld>/?tool-exampleId=3&do=tool-example and I would like to change the part ?tool-exampleId=3&do=tool-example to something like example/3

Is there a way how to do it?

Thanks!

pg
Member | 8
+
0
-

You can do it by adding parameters to the route with names used in the query.

new Route("//<presenter>.<domainName>.<tld>/<do>/<tool-exampleId>/","Presenter:action");

// should generate urls like: presenter.example.com/tool-example/3/

To get rid of prefix “tool”, which is, I suppose, the component name, use Route::FILTER_TABLE.

new Route("//<presenter>.<domainName>.<tld>/<do>/<tool-exampleId>/",array(
	"presenter"=>"Presenter",
	// ... other options
	"do"=>array(
		Route::VALUE => NULL, // no default value
		Route::FILTER_TABLE => array(
			"example"=>"tool-example",
			// and other translations ...
			),
		),
	));

// should generate urls like: presenter.example.com/example/3/

It should work, but there could be some minor adjustments to make.

Last edited by pg (2012-08-26 17:30)

MartyIX
Member | 217
+
0
-

Thanks! It works great!