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.

eZ debug

Timing: Jan 31 2025 01:18:13
Script start
Timing: Jan 31 2025 01:18:13
Module start 'layout'
Timing: Jan 31 2025 01:18:13
Module start 'content'
Timing: Jan 31 2025 01:18:13
Module end 'content'
Timing: Jan 31 2025 01:18:13
Script end

Main resources:

Total runtime0.0248 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.1250151.2109
Module start 'layout' 0.00640.0035 739.3359220.6719
Module start 'content' 0.00990.0132 960.00781,001.8828
Module end 'content' 0.02310.0017 1,961.890637.9922
Script end 0.0248  1,999.8828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002811.1478140.0002
Check MTime0.00114.4624140.0001
Mysql Total
Database connection0.00093.733510.0009
Mysqli_queries0.003714.910230.0012
Looping result0.00000.052810.0000
Template Total0.00124.710.0012
Template load0.00093.701910.0009
Template processing0.00020.946810.0002
Override
Cache load0.00062.525510.0006
General
dbfile0.00031.308980.0000
String conversion0.00000.036540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs