$action=is_numeric($_POST['action']) ? $_POST['action']:'not numeric';
switch ($action)
{
case '1':
$output = "View for action 1- view from a chunk";
$snippetName = "MVC_action1_data";
$params = array('var1'=>$var1);
$view = $etomite->getChunk('MVC_action1_view');
break;
case '2':
$output = "View for action 2- content from a spaghetti-code snippet (or use embedded PHP in a chunk with getChunk() )";
$snippetName = "MVC_action2_data";
$params = array('var1'=>$var1);
$view = $etomite->runSnippet('MVC_action2_view');
break;
default:
$output = "default output- embedded data and view";
$data = $etomite->getIntTableRows("*",
'default_table',
$where ="",
$sort="", $dir="ASC",
$limit="", $push=true,
$addPrefix=true
);
$view = '<a href="{RandomLink}">{Random_Content}</a>';
break;
}
if(!$data) $data = $etomite->runSnippet($snippetName,$params);
$output .= $etomite->mergeCodeVariables($view,
$data,
$prefix="{",$suffix="}",
$oddStyle="",$evenStyle="",
$tag="div"
);
return $output;There are many other patterns, if anyone else has patterns they have found useful or other methods of creating controllers, I (and I'll bet others) woould love to have a peek...
Edited by Cris D., 16 July 2008 - 07:28 PM.











