[TYPO3-ect] tx_lib_controller::_getParameterAction
Steve Ryan
stever at syntithenai.com
Mon Feb 12 00:19:18 CET 2007
Useful?
The original function returns the first key of an action parameter
containing an array.
The new version iterates the array looking for a value indicating that a
user input with name=designator[action][someThing] contains data.
This is particularly useful for buttons where the value is
changeable(and untestable) but only one action subarray index will
contain data for the single button that was pressed.
By naming all HTML buttons this way, any button press will override the
current controller action with it's key.
I have previously found myself in the mess of javascript on buttons to
update a command action. Direct from the POST request is best.
I really like how simple it is with the tx_lib_controller default action.
1. Add a method doStuffAction()
2. Add a button to your template
<input type="submit" name="designator['action']['doStuff']"
value="%%%do_stuff_label%%%" />.
function _getParameterAction($parameters) {
$action = $parameters->get('action');
if(!is_array($action)) {
return $action;
} else {
//return key($action);
// mod by stever
// probably action parameters are coming from buttons named
designator['action'][$actionName]
// use the first action to have a value (ie button was pressed)
$buttonAction='';
foreach ($action as $k=>$v) {
if (strlen(trim($v))>0) {
$buttonAction=$k;
break;
}
}
return $buttonAction;
}
}
Steve Ryan
More information about the TYPO3-team-extension-coordination
mailing list