开发者

Can i create a url like google mail in cake php?

Hi The master CakePHP! I want to ask something.

I think the probem is so simple, Is it possible to generate a url in cakephp application like this? (This is google mail like url - http://mail.google.com/a/domain.com)

http://www.domain.com/a/[something]/[member]/[controller]/[action]

Where [something] is a dynamic variable, [member] is a prefix, [controller] and [action] is usual cakephp url element.

so I want to shift the usual CakePHP url to the right, or insert /a/something/ in the initial url. In addition, [something] should be read from the controller action

thanks, your help would be very valuable to me and will really help me

QUESTION v2: I have tried 开发者_高级运维to add this routing into routes.php

Router::connect('/:code/:something/:controller/:action',
    array(),
    array('code'=>'a','pass'=>array('something'))
);

when i try to access a http://domain.local/a/pte/users/view, it's work, but it display an error when i try to access http://domain.local/a/pte/users

QUESTION v3:

So the simple question is:

How do I have a url like google (example above) without breaking the default CakePHP routing?

QUESTION v4: (Thank's for @Rui)

I tried to create this routing:

Router::connect('/:code/:something/:prefix/:controller/*',
    array(),
    array('code'=>'a','pass'=>array('something'))
);

It's ok when i try to access

http://domain.local/a/pte/member/users (The result is cake render member_index view, It's a great progress :-) ),

but there are several issue:

  1. when i try to access http://domain.local/a/pte/users (without prefix member, i decided to display index function) it's failed (display an error AController did not defined)
  2. When i create a link

    echo $html->link('test link',array('code'=>'a','something'=>'pte','member'=>true,'controller'=>'users','action'=>'another_view'));

it generate a link like this

http://domain.local/member/users/another_view/code:a/something:pte


Please try in /app/config/routes.php:

<?php 
   Router::connect('/a/:something/:member/:controller/:action/*'); 
?>

And the action should be:

<?php 
    public function action($something = null, $member = null) { 
    /* action code */
    } 
?>

Hope it helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜