Questions tagged [cakephp-routing]

Routing is a feature that maps URLs to controller actions.

It was added to CakePHP to make pretty URLs more configurable and flexible. Using Apache’s mod_rewrite is not required for using routes, but it will make your address bar look much more tidy.

Routes in an application are configured in app/Config/routes.php.

Manual Reference.

Example:

Router::connect(
    '/pages/*',
    array('controller' => 'pages', 'action' => 'display')
);

This route is found in the routes.php file distributed with CakePHP. This route matches any URL starting with /pages/ and hands it to the display() action of the PagesController(); The request /pages/products would be mapped to PagesController->display('products').

46 questions
0
votes
0 answers

CakePHP 2.10 Routing one unique slug multiple models

I have been attempting to modify a clients website by allowing /slug to access both the pages and users models/controllers. I have read all of CakePHP 2 Routing book, however it does not go into detail about how to accomplish such a thing. I have…
0
votes
1 answer

CakePHP - routing with wildcards (controller not found error)

I'm not really even sure how exactly to search for this but I have a URL site.com/forum/controller/action Where forum is a plugin and I currently have it routing to the plugin forum successfully with Router::connect('/forum', array('plugin' =>…
David Ryder
  • 1,291
  • 5
  • 14
  • 27
0
votes
1 answer

CakePHP Layout template overriding view template

I have installed CakePHP 3.8 and my layout template (/src/Template/Layout/default.ctp) is completely overriding my controller view (src/Template/Users/login.ctp). I have echo'd & die()'d at the beginning/end of both files, so I know they are being…
jsf
  • 5
  • 3
0
votes
1 answer

Can't access CakePHP API endpoint via ReactJS. Only through the browser

I am trying to build a REST API for my server via CakePHP. I thought I had it working as I can receive the JSON responses via the web browser however when trying to access the same route via ReactJS, the Controllers Action is not actually firing. …
Nate Schreiner
  • 759
  • 2
  • 7
  • 15
0
votes
1 answer

Plain PHP router argument passing to views

I am creating a basic router in PHP, there is not much online material about how to write plain PHP router. So below is my current implementation. Basically every request is redirected to index.php and it then using class router redirects user to…
Austris
  • 49
  • 9
0
votes
0 answers

CakePHP Router not working in PHP class

I'm using CakePHP 3.x+. I have created a library class to download youtube videos using youtube-dl and return local URL of the file. APP/src/Library/AnujTools/YoutubeDownload.php
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
0
votes
2 answers

How to route to a specific method in cakePHP?

my route: Router::connect('/', array('controller' => 'users', 'action' => 'homepage')); Router::connect('/admin', array('controller' => 'users', 'action' => 'dashboard', 'admin' => true)); my Controller class BrandsController extends AppController…
mario
  • 413
  • 1
  • 4
  • 8
0
votes
1 answer

routing in CakePHP 3

I'm working on CakePHP 3.3 I have some dashboard controllers which are named like DashboardUsersController.php, DashboardBusinessesController.php, DashboardCustomersController.php, etc I want to map urls…
Gaurav
  • 131
  • 12
0
votes
1 answer

Make route parameter optional in cakephp

I've created the following route in CakePHP: Router::connect( '/design-idea-projects/:filtertype--:id', array('controller' => 'ourwork', 'action' => 'designideaprojects'), array( 'pass' =>…
Manish Jangir
  • 5,329
  • 4
  • 42
  • 75
0
votes
0 answers

Assign or Execute a controller action to a url if subdomain is found

If a URL will contain a sub domain like http://raddyx.sharemybucket.com./ then I want to execute a controller action for that and the sub domain as its parameter.For Ex for above URL I want execute Users controller and profile action with raddyx as…
pkk
  • 283
  • 4
  • 19
0
votes
1 answer

Listing Cities not in Database in CakePHP

I have an application in CakePHP that lists businesses. I have a business model/controller, as well as a state_list model/controller. However I want to be more detailed so when a user clicks on a State page, it lists all the cities in that…
xtine
  • 2,599
  • 2
  • 18
  • 15
0
votes
1 answer

CakePHP Custom Rest Routing

Our router defines a custom parameter before the controller and action definition: Router::connect( '/:store/:controller/:action/*', array(), array( 'store' => 'shop\/[^\/]+' …
chrony
  • 783
  • 1
  • 8
  • 23
0
votes
0 answers

Redirect routing in CakePHP

I'm trying to set up a CakePHP redirect route, but I'm stuck. Reading the book didn't help so far. I want to redirect the URL /mysite/xyz to /mysite/en/xyz (which includes a language parameter) The route for the final URL, /mysite/en/xyz, is set up…
matk
  • 1,528
  • 2
  • 14
  • 25
0
votes
1 answer

CakePHP access denied

In CakePHP I have this configuration: //Config/routes.php Router::connect('/viewServices', array('plugin' => 'usermgmt', 'controller' => 'services', 'action' => 'viewServices')); //View/Users/dashboard.ctp
SirPilgrims
  • 17
  • 1
  • 5
0
votes
1 answer

CakePHP create route for post with slug and date

Right now I have these routes for my CakePHP blog Router::connect('/blog', array('controller' => 'posts', 'action' => 'index')); Router::connect('/blog/:slug', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug'))); I…
Devin Crossman
  • 7,454
  • 11
  • 64
  • 102