I am ashamed to admit that after 2+ years working with cake and after
reading and re-reading the cookbook I still don't understand how
exactly routing works.
I would like my site to work in this way. I don't even know if it is
possible.
When user enters:
I would like that controller is set to "casinos" language to "notset"
and action set to "index"
this I managed with:
Router::connect('/', array('lang' => 'notset', 'controller' =>
'casinos', 'action' => 'index'));
this was easy
The next part is tricky. I would like that when I entered the path:
http://mysite/controller/
http://mysite/controller/action/
http://mysite/controller/action/params
I would get set controller to controller, action to action and lang to
"notset"
So I added this rule:
Router::connect('/:controller/:action/*', array('lang' => 'notset'));
and it seems to be working ok too.
And now I'd like to do this. On following paths add the lang param
http://mysite/lang/
http://mysite/lang/controller/
http://mysite/lang/controller/action
http://mysite/lang/controller/action/params
f.e http://mysite/de/casinos/index/
so I added this
Router::connect('/:lang/:controller/:action/*', array('lang' =>
'{2}'));
I don't know what {2} stands for. In my case replaces :lang... what I
don't get why numer 2?
and now my problem.
It seems I can't have it both ways. Either I have it without leading
lang param or with it.
I kinda understand that I cant say 2 things at once, that controller
is on the first place and language is on the first place. But I gues
cake is that smart that when the parameter is a controller than
displays it, when it is not a controller than do the second rule (with
lanf as 1st param).
I could do the rules manually for all my controllers and then add
Router::connect('/:lang/:controller/:action/*', array('lang' =>
'{2}'));
like this:
Router::connect('/', array('lang' => 'notset', 'controller' =>
'casinos', 'action' => 'index'));
Router::connect('/casinos/:action/*', array('lang' => 'notset',
'controller'=>'casinos'));
Router::connect('/companies/:action/*', array('lang' => 'notset',
'controller'=>'companies'));
Router::connect('/users/:action/*', array('lang' => 'notset',
'controller'=>'users'));
Router::connect('/countries/:action/*', array('lang' => 'notset',
'controller'=>'countries'));
Router::connect('/configs/:action/*', array('lang' => 'notset',
'controller'=>'configs'));
Router::connect('/comments/:action/*', array('lang' => 'notset',
'controller'=>'comments'));
Router::connect('/news/:action/*', array('lang' => 'notset',
'controller'=>'news'));
Router::connect('/events/:action/*', array('lang' => 'notset',
'controller'=>'events'));
Router::connect('/:lang/', array('lang' => '{2}',
'controller'=>'casinos', 'action'=>'index'));
Router::connect('/:lang/:controller/:action/*', array('lang' =>
'{2}'));
and it works ok, but first I don't know if this is the correct way,
and second, it seems that is slowing down the speed considerably
So any thoughts? Ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment