Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>By variable do you mean GET query string parameters, like in <code>/foo?key=value</code>? You can access them in the controller through <a href="http://book.cakephp.org/2.0/en/controllers/request-response.html#accessing-querystring-parameters" rel="nofollow">the request object</a>: <code>$this-&gt;request-&gt;query['key']</code>.</p> <p>If you are looking for something more integrated you can use CakePHP's default routes or make your own. </p> <p>The <strong>default routes</strong> work with URLs like <code>/controller/action/param1/param2</code> and pass the parameters to the action by position. For instance <code>/posts/view/521</code> maps to a call to <code>view(521)</code> in <code>PostsController</code>, and <code>/posts/byMonth/2012/02</code> maps to a call to <code>byMonth("2012","02")</code>. </p> <p>You can also use named parameters and the URLs look like <code>/controller/action/key1:value1/key2:value2</code>. In controller actions you would read them with <code>$this-&gt;params['named']['key1']</code>.</p> <p>With <strong>custom routes</strong> you can make your URLs anything you want. You're not forced to the /controller/action pattern; you can make <code>/archives/2012-02</code> map to <code>PostsController::byMonth(2012,2)</code>, or have <code>/512-post-title</code> map to <code>PostsController::view(512)</code>.</p> <p>Typically you would start out with the default routes and add custom routes when you decide you need them. You can read all about the default and custom routes in <a href="http://book.cakephp.org/2.0/en/development/routing.html" rel="nofollow">http://book.cakephp.org/2.0/en/development/routing.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload