Pergunta

http://domain.com/foo/c:1

How can I write working router::connect to send such links to

controller=listings
action=search
named array(cat=1) the id I do not know, it's a dynamic url

Please take note, that in the url it is "c" but I need to forward it as "cat".

Thanks in advance!

Foi útil?

Solução

You can specify the routing as follow in the Config/routes.php.

```

Router::connect(
        '/:query/*', array('controller' => 'listings', 'action' => 'search'), array(
            'params' => array('query', 'cat'),
            'named' => array(
                'query', 'cat'
            )
        )
    );

```

and specify the link as

```

echo $this->Html->link('text goes here', array('controller' => 'listings', 'action' => 'search', 'query' => 'foo', 'cat' => 1));

```

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top