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 😉

Advertisements

Entry filed under: cakephp, components.

extended rdAuth Ajax Optimization Techniques

5 Comments Add your own

  • 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?

    Reply
  • 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 🙂

    Reply
  • 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.

    Reply
  • 4. Rjxoekkk  |  July 28, 2007 at 6:00 am

    Greetings!..
    breast augmentation southern california san diego breast augmentation

    Reply
  • 5. Njbuokkk  |  August 1, 2007 at 6:06 am

    interesting thank you…
    florida snook fishing charter clearwater florida charter fishing

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Posts

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

%d bloggers like this: