If you're like me, sometimes you just want to build out a quick action sort of link. You know, like, dropthenerd.com/action/update/$recordID, or dropthenerd.com/post/new. At first I found myself just tacking these on the Page_Controller, and spitting out links like dropthenerd.com/home/myaction/ID/OtherID... but I'm pretty specific in how I like my link structures to look - so I adopted the following approach.
_config.php:
Director::addRules(50, array(
'action' => 'Action_Controller',
));
mysite/code/Action_Controller.php
class Action_Controller extends Controller {
static $allowed_actions = array('post');
function index(){
// do your worst
}
function post(){
// post it
}
}
That's about it - I know, it's pretty simplistic, but you can extend this to whatever you want. Don't forget to add, your action to your $allowed_actions if it's not the index. My favorite part about this approach is the flexibility to keep very specific actions in very specific controllers - and never having to worry about a cumbersom Page_Controller - also, when you just tuck these into Page_controller, if you're also setting up css/javascript includes, then it's loading a whole lot more than just directing you to the one controller you need. It's significantly faster. Just make sure you're not extending Page_Controller.