Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

Re: Passing a session or paramter

$
0
0

That is quite a broad question. For 'click something and execute code' You can use GET parameters. A basic example might look like

<a href="home/?doawesome=1">Do it</a>

On your page in the init() function (or index, or whatever action) you could do something like

class Page_Controller extends ContentController {

public function init() {
...

if($this->request->getVar('doAwesome')) {
// do the awesome, modify the current $this page.
$this->Title = "Some new Title";
}
}
}

Note that if doAwesome is destructive (or modifies the user state) you should protect the link with the Security token to prevent CSFR.

If you want to keep the user on the same page, look at adding a click handler on the link with jQuery and doing the link via $.get().


Posted to: Passing a session or paramter | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles