链接和路由问题

In my view I have the following link:

<?php echo $this->Html->link($article['Article']['title'],  array('category' => $article['Page']['Category']['directory'], 'page' => $article['Article']['page_id'],  $article['Article']['id'])); ?>

I expect the link to output: http://example.com/shows/3/articles/6

My route looks like this:

Router::connect(
    '/:category/:page/:controller/:id',
    array('action' => 'view'),
    array(
        'pass' => array('id'),
        'page' => '[0-9]+',
        'id' => '[0-9]+',
         'category' => 'shows|music|games|books|hobbies',
    )
);

Instead my link is returned like this: http://example.com/articles/6/category:shows/page:3

How do I get this to display properly without using an absolute URL? Is this an issue with my routing, view, link HTML Helper or a combination of the 3? I think the issue is with how the link helper parses the URL but I'm not sure how to change that.

If I enter manually into my browser the url http://example.com/shows/3/articles/16, the correct page is displayed.

I looked into named parameters but that doesn't seem to accomplish what I want either.

You need to include all your params in your pass.

So your route should look like,

Router::connect(
    '/:category/:page/:controller/:id',
    array('action' => 'view'),
    array(
        'pass' => array('category','page','id'), // added all passed params here
        'category' => 'shows|music|games|books|hobbies'
        'page' => '[0-9]+',
        'id' => '[0-9]+'
        // Just re-ordered to match your route ;)
    )
);