Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Given you want to perform one of two or more actions with a single url.
- //
- // in Config/routes.php
- ```
- Router::connect('/:username/:action', array('controller' => 'users', 'action' => 'userOrShop'));
- ```
- ```
- // Your UsersController.php might look something like this then.
- class UsersController extends AppController {
- public function userOrShop() {
- // Do whatever you need to do to determine if the current user is a
- // "shop" or just a user.
- if ($this->User->isShop()) {
- return $this->_doShopThing();
- }
- return $this->_doUserThing();
- }
- protected function _doShopThing() {
- // This is where your regular controller logic would go for when the user
- // is a shop like "BobsShop.
- }
- protected function _doUserThing() {
- // This is where your logic for a username of "Bob" would go.
- }
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement