My routes aren't passing arguments |
[eluser]NSGReaper[/eluser]
So I'm currently working on the file download script for a site. Files can be downloaded either by using: http://mysite/download/34 or http://mysite/download/project.pdf. That is the plan at least, these should be routed to files/getbyid and files/getbyname respectively but while I know that the right function is called no arguments are being passed to it. Code: $route['download/:num'] = "files/getbyid"; Code: class Files extends Controller { With it setup like this I always get the die() message. I have been able to make it work using regex like so: Code: $route['download/([0-9]*)'] = "files/getbyid/$1"; However it was my understanding that these were synonymous. Have I misunderstood the user guide or is something wrong?
[eluser]MikePearce[/eluser]
You have to use the regex if you want to pass things to the controllers. Just using the :num and :any is just a means of mapping one URL to another when you don't know what the first URL might be.
[eluser]NSGReaper[/eluser]
Thanks, I guess I made an assumption rather than misunderstood. Anyway, using regex it works beautifully.
[eluser]alpar[/eluser]
Code: $route['download/(:num)'] = "files/getbyid/$1"; also works
[eluser]NSGReaper[/eluser]
Ah, thanks alpar. I was hoping to find an elegant solution. I think I understand it now too. |
Welcome Guest, Not a member yet? Register Sign In |