Wednesday, April 13, 2011

Re: Help with seo url and settins routers in CakePHP 1.2.10

2011/4/13 Petr Vytlačil <petr.vytlacil@gmail.com>:
> Hi i have problem with setting routering. I need url like: /slug-
> category-somestring-filtertype my router:
>
>        Router::connect('/:slug-somestring-:filtertype',
>                array('controller'=>'goods','action'=>'index'),
>                array('slug' => '[a-zA-Z0-9\-]+','filtertype'=>'c|k','pass' =>
> array('slug','filtertype'))
>        );
>
> link generate:
>
> $html->url(array('controller'=>'goods','action'=>'index','slug'=>
> $mark['Mark']['seourl'],'filtertype'=>'k'));
>
> But this didnt generate url: /slug-category-somestring
>
> If i try this:
>
>        Router::connect('/:slug/somestring/:filtertype',
>                array('controller'=>'goods','action'=>'index'),
>                array('slug' => '[a-zA-Z0-9\-]+','filtertype'=>'c|k','pass' =>
> array('slug','filtertype'))
>        );
>
> generate:      url: /slug-category/somestring/filtertypevalue
>


Is it slug or slug-category? If it's slug where is category coming
from? Same with somestring. How are you passing those to create a
link? And don't you want those passed to the controller?

Router::connect(
'/:slug-:category-:somestring-:filtertype',
array('controller'=>'goods','action'=>'index'),
array(
'slug' => '[-a-z0-9]+',
'category' => '[regexp for category]',
'somestring' => '[regexp for somestring]',
'filtertype'=>'c|k',
'pass' => array('slug', 'category', 'somestring', 'filtertype')
)
);

$this->Html->link(
'click',
array(
'controller'=>'goods',
'action'=>'index',
'slug' => ...,
'category' => ...,
'somestring' => ...,
'filtertype' => ...
)
);

I changed your regexp for slug because it should already be lowercase.
You'll need to create regexps for category and somestring.

If you don't want to pass somestring to the controller just remove it
from the pass array.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate