I ve just installed last 1.7 version of Fuelphp and trying to play without routes, but got stuck a bit

What was done:

Created "special" action in "userspace" controller

public function action_special($a = 'empty')
{
    var_dump($a);
    die();
}

And routing for it

'test(/:any)?' => 'userspace/special/$1'

But the problem is if localhost/test returns

string(5) "empty"

so localhost/test/1 or localhost/test/qwerty returns

string(0) ""

but full path localhost/userspace/special/qwerty returns

string(6) "qwerty"

So somehow our "special" method cant get a parameter from routing.

有帮助吗?

解决方案

Because we're using regular expressions, routes are powerful but sometimes confusing. The regex should be something like:

'something(/(:any))?' => 'something/index/$2',

The (groups) are captured, but :any by itself is not captured, you'll need an extra (group) like the example above. And because it's the second group we'll put $2 in the route translation.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top