Reputation: 25
I have been working on routes and I cant find any examples for dummies-
Can anyone provide some for these scenarios?
lets say the site is www.site.com/test/ test is the controller with action index
Scenario 1 - someone puts www.site.com/test/one
using routing can it send them to index since controller one doesnt exist?
Scenario 2
we create controller two we want www.site.com/test/two to take you to another controller you specify
Scenario 3
lastly we have www.site.com/test/paul/james/
how do we set it up so we get both paul and jame?
thank you
Upvotes: 0
Views: 2568
Reputation: 17000
Scenario 1 (www.site.com/test/one):
You have:
Route::set('s1', '(<controller>(/<level2>))')
->defaults(array(
'action' => 'index',
));
In test
controller you can get one
through $this->request->param('level2').
Scenario 2 (www.site.com/test/two):
Use:
Route::set('s2', 'test/two')
->defaults(array(
'controller' => 'two',
'action' => 'index',
));
Scenario 3 (www.site.com/test/paul/james/):
Use:
Route::set('s3', 'test/<name>/<surname>')
->defaults(array(
'controller' => 'test',
'action' => 'index',
));
Yoy can access paul
through $this->request->param('name') and james
through $this->request->param('surname') in your test
controller.
Upvotes: 2