• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URI Class subfolder and Routing

#1
[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.

#2
[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>';
}

#3
[eluser]OliverHR[/eluser]
Absolutely no.

http://ellislab.com/codeigniter/user-gui...s/uri.html

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

Any ideas?.

#4
[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

#5
[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.

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.