Welcome Guest, Not a member yet? Register   Sign In
Route into a controller sub-directory
#1

[eluser]Edemilson Lima[/eluser]
I am having a problem with a routing...

At my routes.php, I have:

Code:
$route['([a-z]+)/([0-9]+)'] = "$1/details/index/$2";

If I go to: http://www.site.com/products/details/index/3
It works fine.
But, if I do it by the route: http://www.site.com/products/3
It calls products/details/index, but does not send the id code:

Code:
A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Details::index()
Filename: products/details.php
Line Number: 11

"products" is a folder, "details" is the controller and "index" is its default function.
#2

[eluser]wiredesignz[/eluser]
after a lot of testing I found this route works instead oddly enough:
Code:
$route['([a-z]+)/([0-9]+)'] = '$1/details/index/$0';

Can someone explain or do a check on this please.

TIA
#3

[eluser]xwero[/eluser]
is
Code:
$route['([a-z]+)/([0-9]+)'] = "$1/details/$2";
working?
#4

[eluser]Edemilson Lima[/eluser]
No. This was my first try. It returns a 404 page.
#5

[eluser]Edemilson Lima[/eluser]
Code:
$route['([a-z]+)/([0-9]+)'] = '$1/details/index/$0';

This worked for me too! Well, I will use it until another solution be provided.
#6

[eluser]Derek Jones[/eluser]
Some threads are coming close to crossing one another here, but to be thorough, try updating from the SVN, as a related bug was fixed yesterday.
#7

[eluser]Edemilson Lima[/eluser]
No problem, I will wait for the next CI release. =)

My first CI-based project is in the beginning anyway.
#8

[eluser]wiredesignz[/eluser]
Well you didn't have to wait too long after all.
#9

[eluser]sophistry[/eluser]
I grabbed the 1.6 release from the download page today (20080131) and I am seeing these same bugs when using regex routing (my controller is not in sub-dirs):

http://ellislab.com/forums/viewthread/48779
http://ellislab.com/forums/viewthread/50795/

to sum up... regex routes set segments properly but don't send them as controller parameters properly.
so, when i put a regex route like this:

Code:
$route['[a-z]{3}'] = "welcome/index/$1";

the parameter sent to the controller function is the literal string dollarsign1 ($1). I also tried $0 and that did the same thing.

but, the segment_array() method shows the right data - it has the string captured by the regex.

i checked the bug forum and this was the latest talk about it.

is this expected behavior? should i just use the $this->uri->segment(n) method and be done?
#10

[eluser]Edemilson Lima[/eluser]
Did you try the expression inside parenthesis?

Code:
$route['([a-z]{3})'] = "welcome/index/$1";

Aren't the parenthesis that determine what will become $1, $2, $3, etc?




Theme © iAndrew 2016 - Forum software by © MyBB