CodeIgniter Forums
Routing Problem: passing a URL segment as variable to function call - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Routing Problem: passing a URL segment as variable to function call (/thread-53767.html)



Routing Problem: passing a URL segment as variable to function call - El Forum - 08-08-2012

[eluser]kingmaoam[/eluser]
Hi,

I have a problem with the routing in my CI project.

To start this right: yes I have read the User Guide and adopted the "news" tutorial to get the expected behaviour.

What I have is this:

in my routes.php
Code:
$route['admin/sub/(:any)'] = 'admin/admin/loader/$i';

in the admin controller located in controller/admin:
Code:
public function loader($var)
{
   echo $var;
}

On calling the URL http://urltomyproject.de/admin/sub/content I expect to get echoed 'content' but what I get is '$i' as string.

What have I forgotten to do?

KR
kingmaoam


Routing Problem: passing a URL segment as variable to function call - El Forum - 08-08-2012

[eluser]InsiteFX[/eluser]
It uses numeric digitals not $i shuld be $1 $2 etc;
Code:
$route['admin/sub/(:any)'] = 'admin/admin/loader/$1';



Routing Problem: passing a URL segment as variable to function call - El Forum - 08-08-2012

[eluser]kingmaoam[/eluser]
Hi,

thanks a lot. I was thinking about this problem for hours now and then it's that simple...

DOH...