Fez workflow behaviour template
I just started work on a behaviour for a new workflow in Fez and had a quick fish around for another workflow to base it on. I realised that for a ‘non-auto’ behaviour, preview.php is a good place to look as it just has the workflow wrapper code and then includes another file.
include_once("../config.inc.php");
include_once(APP_INC_PATH . "class.template.php");
include_once(APP_INC_PATH . "class.workflow_status.php");
// include whatever else you need here
$tpl = new Template_API();
// set the workflow wrapper template
$tpl->setTemplate("workflow/index.tpl.html");
// set the template that the workflow template will include
$tpl->assign('type',"preview");
// restore WorkflowStatus object from the session
$wfstatus = &WorkflowStatusStatic::getSession();
$pid = $wfstatus->pid;
// set up the basic templates variable you need for a workflow
$wfstatus->setTemplateVars($tpl);
// handle any form input processing here
// check if the user clicked a button to go to another state
$wfstatus->checkStateChange();
// Do all your display work for generating the form and page content
$tpl->displayTemplateRecord($pid);
Simple eh?

