nice referral link |
[eluser]Dariusz-Gdynia[/eluser]
is there any chance to produce nice-looking referral link in CI? I know I can have www.domain.com/controller/function/id but can I have something else? I need to read idUser from that link, move it to $this->session->userdata, and finally use it when somebody is going to register.
[eluser]pistolPete[/eluser]
[quote author="Dariusz-Gdynia" date="1236627731"]I know I can have www.domain.com/controller/function/id but can I have something else?[/quote] You can do almost everything you want to (using routing / .htaccess etc.), but if you don't specify how it should look like it's hard to tell.
[eluser]Dariusz-Gdynia[/eluser]
the shorter the better I think. So if it could be like www.domain.com/124 it would be great. But I have no idea how :/
[eluser]Dariusz-Gdynia[/eluser]
that works almost great ![]() As I presume the is no option for www.domain.com/124 ?
[eluser]pistolPete[/eluser]
Try something like this: Code: $route['(:num)'] = "controller/method/$1";
[eluser]drewbee[/eluser]
I actually had a requirement for this, except for the fact that it could be attached to ANY uri. Obviously i wasn't going to hard code this into every controller. I used the pre_controller hook to handle this situation as well as cookies. Pre Controller hook: (note: most of CI is not intiallized by this point, so we just have to do some good old fashion PHP'in here); Code: if (isset($_GET['refid')) Now anywhere in our application we can simply retrieve the cookie data as needed. As well, any page can now be used as a referal page. /controller/method/param/param.html?refid=drewbee /controller.html?refid=drewbee etc.
[eluser]Dariusz-Gdynia[/eluser]
[quote author="pistolPete" date="1236630567"]Try something like this: Code: $route['(:num)'] = "controller/method/$1"; after that I tried www.domain.com/1 and it's not working... Code: 404 Page Not Found drewbee => the case is short URL, not retrieving id ![]()
[eluser]pistolPete[/eluser]
How does your route look like? controller/method/$1 was just an example, you have to adjust it according to your controllers/methods.
[eluser]Dariusz-Gdynia[/eluser]
yes, yes, I know that ![]() In my case it is $route['recommend/(:num)'] = "welcome/index/$1"; $route['(:num)'] = "welcome/index/$1"; in first case it's working in second it doesn't, I tried even with slash $route['/(:num)'] and still nothing :/ |
Welcome Guest, Not a member yet? Register Sign In |