Reputation: 3164
I want to use the router of cake for friendly urls. My urls are of this type:
http://domain/some_text/categories/view/4/5/6
http://domain/other_text/articles/read/new-stuff
http://domain/xyz_text/charts/list/latest/10
The basic idea is that the first part of the url (some_text, other_text, xyz_text)
will be forwarded as a parameter to the action, but not as a named parameter.
HtmlHelper:link()
method? (some tests gave me http://domain/Controller/action/params../some_name:some_text
...)Upvotes: 0
Views: 118
Reputation: 11574
You can do something like this, but you will need to build one for each controller. Here is the example for the categories controller you listed in your question:
http://domain/some_text/categories/view/4/5/6
Router::connect(
'/:pagevar/:controller/:action/*',
array(
'controller' => 'categories',
'action' => 'view',
),
array(
'pass' => 'pagevar'
)
);
Then to access the 'some_text' var, you can just reference it through the params:
$this->params['pagevar']
I'm not sure this is exactly what you want to hear, but it may give you some ideas where to build from.
Upvotes: 1