Workflow and templates

Author Message

Clemens T

Monday 02 June 2008 6:06:56 am

Heya all,

I've got the following setup:

<b>Trigger 1</b>: BEFORE Publish - triggers: Workflow 1

<b>Workflow 1</b>: multiplexer event to 'filter' items of one class - run Workflow 2 on these

<b>Workflow 2</b>:
- do my CustomEventType and then finish the publishing

My CustomEventType is:

    function execute( &$process, &$event )
    {
	$http =& eZHTTPTool::instance();

	if($http->hasPostVariable("done"))
	{
		return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
	} 
	else
	{
	      $requestURI = eZSys::requestURI();
		
              $process->Template = array();
              $process->Template['templateName'] = 'design:workflow_event.tpl';
              $process->Template['templateVars'] = array ( 'event' => $event );
						
	      return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE_REPEAT;
	}
    }

Template code:

<form method="post">
<input type="hidden" name="done" />
<input type="submit" name="submit" value="Done with this workflow" />
</form>

The template is loaded fine, but after I hit the button, it returns to the edit form where I can edit the news item again. This probably has something to do with the <form ...> tag.

How can I make sure that submitting the form will not lead to a step back in the workflow, but in a step forward?

Greets,
Clemens

Clemens T

Monday 02 June 2008 8:16:36 am

Got it!

This is not documented or whatever, but my thanks goes to the following thread:http://ez.no/developer/forum/developer/before_publish_event_with_tempaltes

The key is publishing data without publishing new object info via:
<b>HasObjectInput</b> and<b>PublishButton</b>.

My very simple template code now looks like this:

<form method="post" action="{"/content/action/"|ezurl(,'no')}">
	<input type="hidden" name="HasObjectInput" value="0" />
	<input type="hidden" name="done" value="1" />
	<input class="button" type="submit" name="PublishButton" value="Finish" />
</form>

My Execute function:

    function execute( &$process, &$event )
    {
	$http =& eZHTTPTool::instance();

	if($http->hasPostVariable("done"))
	{
		
                //do anything I want to do...				
		return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
	} 
	else
	{
		$requestURI = eZSys::requestURI();
		
              $process->Template = array();
              $process->Template['templateName'] = 'design:workflow_event.tpl';
              $process->Template['templateVars'] = array ( 'event' => $event );
 
						
		return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE_REPEAT;
	}
    }

Andrew Duck

Thursday 29 January 2009 5:08:51 am

Is this functionality still available in eZ 4.0.1?

My use case is eZWorkflowEventType::STATUS_FETCH_TEMPLATE_REPEAT to load up the first template which works fine, but then submitting data from this template back to the workflow event for evaluation and further processing does not appear to work.

Is this possible with the content module, content/action?

I have attempted posting data to /content/action with and without HasObjectInput but I end up at the object history page forcing me to create a new draft.

Andrew Duck, Executive Director, Quiqcorp Limited
eZ Certified Developer and Trainer.
Member of the Community Project Board
http://quiqcorp.com | http://twitter.com/andrewduck

Kristof Coomans

Friday 30 January 2009 6:36:42 am

Issue reported here by Andrew: http://issues.ez.no/IssueView.php?Id=14371

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.