Permalink
Browse files

Refs #157 Changing the plugins defaults from named parameters to quer…

…y strings
  • Loading branch information...
burzum committed Jul 24, 2014
1 parent fdac4c3 commit 2638972efed5774eab49546691de61069196a40f
@@ -66,12 +66,12 @@ class PrgComponent extends Component {
'action' => null,
'modelMethod' => 'validateSearch',
'allowedParams' => array(),
'paramType' => 'named',
'paramType' => 'querystring',
'filterEmpty' => false
),
'presetForm' => array(
'model' => null,
'paramType' => 'named'
'paramType' => 'querystring'
)
);
@@ -0,0 +1,37 @@
Named Params vs Querystring
===========================
With the release of **2.5.0** of the **Search** plugin the default settings for the prg component have been changed to use `querystring` by default instead of `named`.
To use querystrings **before 2.5.0** you have to use these configuration settings for the component.
```php
public $components = array(
'Search.Prg' => array(
'commonProcess' => array('paramType' => 'querystring'),
'presetForm' => array('paramType' => 'querystring')
)
);
```
If you just **upgraded to 2.5.0** or higher, and you're not already using query strings you'll have to set the configuration of the prg component in your app back to use named parameters. This is as well valid if you want to favor named parameters for some over query strings.
```php
public $components = array(
'Search.Prg' => array(
'commonProcess' => array('paramType' => 'named'),
'presetForm' => array('paramType' => 'named')
)
);
```
Why Querstrings Instead of Named parameters?
--------------------------------------------
[Query strings](http://en.wikipedia.org/wiki/Query_string) are the correct way of passing parameters in an URL while historically named parameters were always just a hack to get pretty URLs in CakePHP.
When you pass named parameters that contain special characters like `/` or `&` for example, they'll break the URL. You will have to manually encode and decode them all the time.
The encoding of named parameters can break URLs. They always violate the [HTTP specification](http://tools.ietf.org/html/rfc3986#section-2.2) and they are CakePHP specific, no other application uses volatile parameters this way and are no real standard.
Named parameters are not any longer supported in CakePHP 3.0 as well.
View
@@ -14,6 +14,7 @@ Documentation
* [Overview](Documentation/Overview.md)
* [Installation](Documentation/Installation.md)
* [Named Parameters vs Query Strings](Documentation/Named-Parameters-vs-Query-Strings.md)
* [Configuration](Documentation/Configuration.md)
* [POST-Redirect-GET Pattern](Documentation/Post-Redirect-Get.md)
* [Examples](Documentation/Examples.md)
@@ -45,7 +45,13 @@ class PostsTestController extends Controller {
*
* @var array
*/
public $components = array('Search.Prg', 'Session');
public $components = array(
'Search.Prg' => array(
'commonProcess' => array('paramType' => 'named'),
'presetForm' => array('paramType' => 'named')
),
'Session'
);
/**
* beforeFilter
@@ -57,7 +63,8 @@ public function beforeFilter() {
$this->Prg->actions = array(
'search' => array(
'controller' => 'Posts',
'action' => 'result')
'action' => 'result'
)
);
}

0 comments on commit 2638972

Please sign in to comment.