Try this:

Router::connect(
        '/noticias/:id',
        array('controller' => 'news', 'action' => 'view'),
        array(
                'pass' => array('id'),
                'id' => '[0-9]+'
        )
);

function view($id = null)
{
    ....

On Wed, Jun 24, 2009 at 5:14 AM, Juan Delgado<[email protected]> wrote:
>
> Hi again,
>
> Now that I've come back to this, I'm finding out that it doesn't seem
> to be possible to do what I want to do. Which is:
>
> /mycontroller/ // <-- goes to mycontroller + index, shows pagination
> /mycontroller/page:x // <-- should go to mycontroller + index,
> straight to page x
> /mycontroller/id // <-- goes to mycontroller + view
>
> What I'm doing at the moment is catching up this route:
>
> /mycontroller/page:x
>
> on the view action and redirect with something like this:
>
> $params = Router::getParams();
> if(array_key_exists("page", $params["named"])){
>        $this->redirect(array('controller' => 'mycontroller', 'action' =>
> 'index', 'page' => $params["named"]["page"]));
> }
>
> That works but takes the user to:
>
> /mycontroller/index/page:x
>
> Note the "index" action on the url which is what I want to avoid in
> the first place.
>
> This would work if I could catch a route like this in routes.php:
>
> Router::connect('/mycontroller/page:*', array('controller' =>
> 'mycontroller', 'action' => 'index'));
>
> But doesn't seem to work.
>
> Any ideas more than welcome.
>
> Ta!
>
> Juan
>
> On Jun 10, 11:48 am, Juan Delgado <[email protected]> wrote:
>> Hi there,
>>
>> I'm having some trouble with the links in the paginator. I've read the
>> docs and searched on the mailing list, but can't find the exact
>> combination.
>>
>> I'd like a structure like this:
>>
>> /noticias
>> /noticias/page:x
>> /noticias/id
>>
>> First link brings all the news. Second link brings the pagination of
>> all the news. Last link, though, should be the view of a specific
>> pieces of news.
>>
>> I have these routes defined (please note that the url is not the same
>> as the name of the controller):
>>
>> Router::connect('/noticias', array('controller' => 'news', 'action' =>
>> 'index'));
>> Router::connect('/noticias/*', array('controller' => 'news', 'action'
>> => 'view'));
>>
>> But this generates links like this:
>>
>> /news/index/page:x
>>
>> I've tried 1000 combinations between the Router and the paginator but
>> to no avail.
>>
>> Any help much appreciated!
>>
>> Juan
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to