Archive for July 25th, 2006

get rid of GET

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 ;)

5 comments July 25, 2006


Top Posts

Recent Posts

a

bakers

feeds

general

uncategorized

Archives

Recent Comments

reviews on About
vishal on CakePhp Coding Standards
Ezoteraa on new installation of cake: open…
lanamep on new installation of cake: open…
marthavos on new installation of cake: open…

 

July 2006
M T W T F S S
« Jun   Aug »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Meta