CodeIgniter Forums
URI Class subfolder and Routing - 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: URI Class subfolder and Routing (/thread-44237.html)



URI Class subfolder and Routing - El Forum - 08-08-2011

[eluser]OliverHR[/eluser]
I'm a little confused, why URI library never return subfolders name when using a route.

Let me show my problem, I definded this route:

Code:
$route['product/(:num)'] = 'admin/products/detail/$1';

Where:

"admin" is a subfolder in the controllers folder.
"products" is a controller
"detail" is a function who expects a numeric parameter

I must say that everything works fine, but if i try to use the next code:

Code:
function detail($id = 0)
{
  echo '<pre>';
    print_r($this->uri->segment_array());
    print_r($this->uri->rsegment_array());
  echo '</pre>';
}


Using the url "http://localhost/product/1" I get this:

Quote:Array
(
[1] => product
[2] => 1
)

Array
(
[1] => products
[2] => detail
[3] => 1
)

And The subfolder?...


But, if I use the full url "http://localhost/admin/products/detail/1" I get:

Quote:Array
(
[1] => admin
[2] => products
[3] => detail
[4] => 1
)

Array
(
[1] => products
[2] => detail
[3] => 1
)

Thank's in advance for any help.


URI Class subfolder and Routing - El Forum - 08-08-2011

[eluser]Bart v B[/eluser]
Code:
function detail($id = 0)
{
  echo '<pre>';
    print_r($this->uri->segment_array());
    print_r($this->uri->rsegment_array());
  echo '</pre>';
}

maybe it is a write misstake on the seccond line?

Code:
function detail($id = 0)
{
  echo '<pre>';
    print_r($this->uri->segment_array());
    print_r($this->uri->segment_array());
  echo '</pre>';
}



URI Class subfolder and Routing - El Forum - 08-08-2011

[eluser]OliverHR[/eluser]
Absolutely no.

http://ellislab.com/codeigniter/user-guide/libraries/uri.html

-----------------

Any ideas?.


URI Class subfolder and Routing - El Forum - 08-08-2011

[eluser]Bart v B[/eluser]
i am sorry, my bad, was thinking that you had a other problem..
It's actually quite logical.
Tells you the route you want to rewrite any other way.
Admin folder that no longer comes through for you because CodeIgniter compels him to rewrite.
So you're saying basically the controller is not admin, but products.
It looks a bit like modRewite only via PHP.
Apache voodoo, but slightly different.
Because as you can see, you 'original' url uses.
You only have to know. Wink


URI Class subfolder and Routing - El Forum - 08-08-2011

[eluser]OliverHR[/eluser]
Actually the problem is not the routing stuff.


The problem is with URI library this library have functions that return info about segments on the URL routed or not.

But the error or bug comes when you get info for a controller function routed if the controller is on a subfolder, because URI library functions dont retrieve folders name.


URI Class subfolder and Routing - El Forum - 08-13-2011

[eluser]OliverHR[/eluser]
No one have a clue how get full segments when using routing using URI library?.