Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function index()
- {
- $this->set('posts', $this->Portfolio->find('all'));
- }
- function view ( $id, $slug )
- {
- $post = $this->Portfolio->read(null, Tiny::reverseTiny($id));
- $this->set(compact('post'));
- }
- Router::connect('/portfolio/*',
- // * is a wildcard matching anything & everything after /portfolio/
- array('controller' => 'portfolio',
- // and routing to portfolio's view() action, with or w/o required $args to pass
- 'action' => 'view'));
- // Targets inside the controller (its methods)
- Router::connect('/portfolio/',
- array('controller' => 'portfolio', 'action' => 'index'));
- // Targets the controller
- Router::connect('/portfolio',
- // Specifies the default controller action, can be whatever
- array('controller' => 'portfolio', 'action' => 'index'));
- // Targets the controller
- Router::connect('/portfolio',
- // Routes to 'controller default method' which is index() by Cake default
- array('controller' => 'portfolio');
- Router::connect('/portfolio/',
- // the trailing DS changes it to target 'inside portfolio' instead of 'portfolio'
- array('controller'=>'portfolio', 'action'=>'index'));
- // trailing arbitrary wildcard maps any / all actions directly to view() method
- Router::connect('/portfolio/*',
- array('controller' => 'portfolio', 'action' => 'view'));
- // catches portfolio/index() without index in the url
- Router::connect('/portfolio',
- array('controller' => 'portfolio'));
- // maps to portfolio/view() without view in url, just /portfolio/integer id
- Router::connect('/portfolio/:id',
- array('action'=>'view', array('id' => '[0-9]+'));
- // routes everything else in portfolio as usual
- Router::connect('/portfolio/:action/*',
- array('controller'=>'portfolio'));
- Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
- Router::connect('/portfolios/*', array('controller' => 'portfolios', 'action' => 'view'));
Add Comment
Please, Sign In to add comment