Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Router::connect static parameters #607

Closed
xmeltrut opened this Issue · 6 comments

2 participants

@xmeltrut

According to the manual, you can pass static parameters into routes.

Router::connect('/socks', array('Products::view', 'id' => 72739));

However, this doesn't seem to work in practice.

Router::connect('/blog', array('Articles::index', 'id' => 123));
Router::connect('/test', array('Articles::post', 'slug' => 'hello-world'));

Both of those generate a missing argument 1, or given default values, remain blank.

@nateabele
Owner

Your syntax definitely looks correct. Can you show me what you're calling to generate the actual links (i.e. calling the Router directly vs. using a helper method, etc.)?

@xmeltrut

Helper method in the view? I'm not using any at the moment, I just connected the route up in my bootstrap/routes.php file and punched it in manually.

@nateabele
Owner
@xmeltrut

Sorry, yes, I'm just talking about trying to load the page by browsing to /blog. So in theory it should be connected up to my Articles::index method and send id as a parameter, unless I've misunderstood.

class ArticlesController extends Controller {

    public function index ($id) {
        $article = Article::getRepository()->findBy(array('id' => $id));
        return compact('article');
    }

But if I run this, it doesn't pass the argument through, and I get a missing argument 1 error.

@nateabele
Owner
@xmeltrut

Ah ok, thanks.

@nateabele nateabele closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.