We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

OW_Route custom url? | Forum

Topic location: Forum home » Support » General Questions
Marcus
Marcus Nov 21 '18

How do I capture urls like these: site.com/test-1-2-id-to-catch


OW::getRouter()->addRoute(new OW_Route('test.index', 'test-1-2:id', "TEST_CTRL_Test", 'index'));



The Forum post is edited by Marcus Nov 21 '18
Oxwall Germany Club
Oxwall Germany Nov 21 '18
Yes, that is right, but don't forget to add a slash before the parameter. So you will have site.com/test-1-2/id-to-catch . In addition, the controller must be valid.
The Forum post is edited by Oxwall Germany Nov 25 '18
Marcus
Marcus Nov 23 '18
Thanks Oxwall Germany the problem is that for some reason it redirects all urls to that controller and the ID part is not isolated at all in $params array. Shows like this [test-1-2:id] -> then URL
The Forum post is edited by Marcus Nov 23 '18
Mike
Mike Nov 24 '18

Hey,


you cant mixup url and Parameter.

Parameter have to be seperated by /


So it shpuld look like: test-1-2/:id

Or with more Parameters: test/:id1/:Name/:Nothing/normaletext


And then in the Controller:

public function index($params){

 $params["id"]; //There is your id

}

The Forum post is edited by Mike Nov 24 '18
Marcus
Marcus Nov 28 '18
Thanks Mike that explains everything gotta come up with a way around that. Any suggestions will be hugely appreciated.
The Forum post is edited by Marcus Nov 28 '18