get rid of GET
July 25, 2006 at 12:29 pm 5 comments
SimpleGet Component
What?
SimpleGet is a component that manipulates the pass in the params array. It works much like the GET. I can better explain it thru an example. Let’s say we have the ffg url: http://controller/action?var1=value. Using the component, we can rewrite it as http://controller/action/var1/value. Then in the controller, we can ask for var1′s value easily.
How?
Add the Simple Get Component to your components folder.
class YourController extends AppController {
var $components = array('SimpleGet');
function index() {
// returns false if var1 does not exist
$var1 = $this->SimpleGet->getValueOf('var1');
// the rest of your code here
}
/* Initialize the SimpleGet component with the value from
* $this->params[pass]. You must pass all the $this->params
* bec sometimes $this->params[pass] does not exist. Let the
* component check for this.
* You dont have to always set the params in your code bec it
* is done at the startup of your controller. This is only
* used just in case it is needed (a call from ajax maybe)
*/
function resetParams() {
$this->SimpleGet->init($this->params);
}
}
SimpleGet already sanitizes the value passed to you so you dont have to sanitize it again.
Why name it like that?
hmmm.. Im no good at naming things.. hehehe.. I created this one to replace it with the ugly GET url so its simply GET for me
Entry filed under: cakephp, components. Tags: .
1.
GreyCells | November 29, 2006 at 10:18 pm
Hi
This is an excellent idea, but unfortunately the link to the component seems to be broken. Any chance of calling the repair man?
2.
cakensoda | December 2, 2006 at 8:18 am
@GreyCells: sorry for the delay in updating it, been busy lately. Hope it’ll be useful to you
3.
gian | May 17, 2007 at 8:57 am
hi. im currently applying your codes to my portal. The code is running but its not the output as i was expecting.id from the Url is not passing to the other pop-up window i need to get the id for me to display on the generated cake codes. the id is from joomla codes to cake files.
4.
Rjxoekkk | July 28, 2007 at 6:00 am
Greetings!..
breast augmentation southern california san diego breast augmentation
5.
Njbuokkk | August 1, 2007 at 6:06 am
interesting thank you…
florida snook fishing charter clearwater florida charter fishing