开发者

How to Create This Route in CakePHP

I want to create a ro开发者_开发百科ute something like:

http://images.example.com/[models]/[sizes]_[filename].[extension]

[models] = (blog|event|user) [sizes] = (t|s|l|o) [filename] = example [extension] = (png|gif|jpg)

How do I create the route for this? I've tried the following w/ no success:

Router::connect('/:model/:size\_:filename.:extension', 
array('controller' => 'images', 'action' => 'server'),array( 
                'model'=>'(blog|event|users)+', 
                'size'=>'(t|m|l|o)', 
                'filename'=>'\w+', 
                'extension'=>'.(gif|png|jpg)', 
                ));


I think you'll be able to do what you want through a custom route class (if you're using CakePHP 1.3+).

Check out this blog post for more information.


should be like this:

Router::connect('/:model/:size_:filename.:extension', 
array('controller' => 'images', 'action' => 'server'),array( 
                'model'=>'(blog|event|users)', 
                'size'=>'(t|m|l|o)', 
                'filename'=>'\w+', 
                'extension'=>'(gif|png|jpg)', 
                ));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜