Welcome Guest, Not a member yet? Register   Sign In
routing and subfolder problem
#1

[eluser]easymind[/eluser]
I have:
Code:
in: controllers/ttt
file: welcome.php
a function:
function test($var1=false,$var2=false,$var3=false)
{
    echo $var1;
    echo $var2;
    echo $var3;
}

this url: http://xxx.xx/ttt/welcome/test/1/2/3
generates: 123

then a routing: $route["en/(.*)"] = "$1";
and this url: http://xxx.xx/en/ttt/welcome/test/1/2/3
generates: test12

So somehow the position of the arguments to the subfoldered function are not routed correctly, or I need to use a different syntax. What is the problem here?

Code:
$route["english/(:any)"] = "$1";
gives the same bad argument values

$route["english/(:any)"] = "/$1";
works good but gives 404 if controller is in a subfolder

I even noticed that putting folders inside a folder in your controller (so if you go 2 deep) you always get a 404 without routing...
#2

[eluser]easymind[/eluser]
Ok, I have found this fix in the bug reports:

Proposed fix (only for the current svn version):
1- In URI.php (this is now in Router.php) change the snippet of code in _reindex_segments() to accurately compare the 2 segment arrays from :
$diff = (count(array_diff($this->rsegments, $this->segments)) == 0) ? FALSE : TRUE;

to:
$diff = (count(array_diff($this->segments, $this->rsegments)) == 0) ? FALSE : TRUE;

2- In system/codeigniter/CodeIgniter.php, change the snippet of code that slice $rsegments to find the request’s arguments. Whether the controller is in a subdirectory or not, $rsegments will no longer have that information and should be treated the same regardless.

From:
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, (($RTR->fetch_directory() == ‘’) ? 2 : 3)));

To:
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
(now $URI->rsegments needs to be $this->rsegements)

(bold additions is for version 1.5.4)


I am glad I can do my languages thing now. But CI still doesn't let you go 2 or more deep inside your controller map.

Original bug fix.: http://codeigniter.com/bug_tracker/bug/2849/




Theme © iAndrew 2016 - Forum software by © MyBB