Problem solved! I just took the () off the rule.
this
$regra = "(".substr($regra, 0,-1).")";
become this
$regra = substr($regra, 0,-1);
On Sat, Oct 6, 2012 at 12:04 PM, Kico Zaninetti <[email protected]>wrote:
> Hi, I'm having a problem and don't know where is the problem, maybe
> someone can help me out.
>
> I have created the following routes:
>
> foreach($cats as $cat) {
> $regra .= $cat["Categoria"]["url_rapida"]."|";
> }
> $regra = "(".substr($regra, 0,-1).")";
> // this return the structure
> (category-name|category-other-name|products|etc)
>
> //this route works fine
> Router::connect(
> '/:categoria_slug', array(
> 'controller' => 'categorias',
> 'action' => 'view'
> ), array(
> 'categoria_slug' => $regra
> )
> );
> //this route works fine
> Router::connect(
> '/:categoria_slug/page::page', array(
> 'controller' => 'categorias',
> 'action' => 'view'
> ), array(
> 'categoria_slug' => $regra,
> 'page' => '[0-9]+'
> )
> );
>
>
> Router::connect(
> '/:categoria_pai/:subcategoria', array(
> 'controller' => 'categorias',
> 'action' => 'view'
> ), array(
> 'categoria_pai' => $regra,
> 'subcategoria' => '[\w-_]+'
> )
> );
>
> Router::connect(
> '/:categoria_pai/:subcategoria/page::page', array(
> 'controller' => 'categorias',
> 'action' => 'view'
> ), array(
> 'categoria_pai' => $regra,
> 'subcategoria' => '[\w-_]+',
> 'page' => '[0-9]+'
> )
> );
>
>
> The problem is on the last two Routes. When I access the following:
>
> http://localhost/mywebsite/category-name/subcategory
>
> It should return to my controller this two parameters:
>
> $this->params["categoria_pai"] => "category-name"
> $this->params["subcategoria"] => "subcategory"
>
> BUT, it is repeating the first value on the two parameters:
>
> $this->params["categoria_pai"] => "category-name"
> $this->params["subcategoria"] => "category-name"
>
> Any ideas??
>
> Thanks in advance.
>
> Kico
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> 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].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
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].
Visit this group at http://groups.google.com/group/cake-php?hl=en.