Provide configurations without workflow-ng's helper functions

Last modified: December 7, 2007 - 13:57

It's possible to specify the configuration without the helper functions. The advantage of this method, is that it's possible to create the new configuration using workflow-ng's UI and using the export function. The export is a working configuration, which can be used like this:

<?php
/*
* Implementation of hook_configuration()
*/
function yourmodule_configuration() {
 
$configurations = ....EXPORT.....;
  return
$configurations;
}
?>

So let's show how our example "Print the content title of content" on content view would like, if one specifies it as structured array:

<?php
/*
* Implementation of hook_configuration()
*/
function yourmodule_configuration() {
 
$configurations = array();
 
$configurations['module1'] = array(
   
'#type' => 'configuration',
   
'#name' => 'module1',
   
'#label' => 'Print the content title of pages and stories',
   
'#event' => 'node_view',
   
'#module' => 'workflow-ng-ui',
  );
 
$configurations['module1']['logical_or'] = array(
     
'#type' => 'OR',
  );
 
$configurations['module1']['logical_or']['is_page'] = array(
   
'#type' => 'condition',
   
'#name' => 'workflow_ng_condition_token_compare',
   
'#label' => 'Is page',
   
'#settings' => array(
      
'text1_args' => array('node'),
      
'text1' => '[node:type]',
      
'text2_args'=> array(),
      
'text2' => 'page',
     ),
  );
 
$configurations['module1']['logical_or']['is_story'] = array(
   
'#type' => 'condition',
   
'#name' => 'workflow_ng_condition_token_compare',
   
'#label' => 'Is story',
   
'#settings' => array(
      
'text1_args' => array('node'),
      
'text1' => '[node:type]',
      
'text2_args' => array(),
      
'text2' => 'story',
     ),
  );
 
$configurations['module1']['action1'] = array(
   
'#type' => 'action',
   
'#name' => 'workflow_ng_action_drupal_message',
   
'#label' => 'Show the title of this node',
   
'#settings' => array(
     
'message' => 'Workflow-ng example: The title of this post is [node:title]',
     
'message_args' => array('node'),
    ),
  );
  return
$configurations;
}
?>

Be sure to choose a unique configuration name, prefixed with your module's name and use it instead of "module1" in the example above.

In order for me to

Max_Headroom - September 23, 2008 - 09:40

In order for me to understand how to convert an export output to a structured array, I made comments on the export output where the changes are made. Hope it helps somebody else understand it better.

<?php
array (//this goes
 
'config1' =>array (//$configurations['module1'] = array(
   
'#type' => 'configuration', // moved here for clarity
   
'#name' => 'config1', //#name=> 'module1', // moved here for clarity
   
'#label' => 'Print the content title of pages and stories',
   
'#event' => 'node_view',
   
'#module' => 'Workflow-ng-ui',
   
'#active' => false,
   
  
//) //close $configurations['module1'] array here
  
   
0 =>array ( //$configurations['module1']['logical_or'] = array(
     
'#type' => 'OR',
                     
     
//) //close $configurations['module1']['logical_or'] array here
     
     
0 =>array (//$configurations['module1']['logical_or']['is_page'] = array(
       
'#type' => 'condition',
       
'#name' => 'workflow_ng_condition_token_compare',// moved here for clarity
       
'#label' => 'Is page',
       
'#settings' =>array (
         
'regex' => 0, //remove
         
'text1' => '[node:type]',
         
'text1_args' =>array (0 => 'node', ),// 'text1_args' => array('node'),
         
'text2_args' =>array (),
         
'text2' => 'page',
          ),
      ),
//remove",", replace with ";"
     
     
1 =>array ( //$configurations['module1']['logical_or']['is_story'] = array(
       
'#type' => 'condition',
       
'#name' => 'workflow_ng_condition_token_compare',// moved here for clarity
       
'#label' => 'Is story',
       
'#settings' =>array (
         
'regex' => 0, //remove
         
'text1' => '[node:type]',
         
'text1_args' =>array (0 => 'node', ),//'text1_args' => array('node'),
         
'text2_args' =>array (),
         
'text2' => 'story',
        ),
      ),
//remove",", replace with ";"
   
), //remove: "or" array now close above
   
   
1 =>array ( //$configurations['module1']['action1'] = array(
     
'#type' => 'action',
     
'#name' => 'workflow_ng_action_drupal_message',// moved here for clarity
     
'#label' => 'Show the title of this content',
     
'#settings' =>array (
       
'message' => 'Workflow-ng example: The title of this post is [node:title]',
       
'message_args' =>array (0 => 'node', ),//'message_args' => array('node'),
       
'error' => 0,
      ),     
    ),
//remove",", replace with ";" 
 
),// remove: $configurations['module1'] array now close above
);//this goes
?>

 
 

Drupal is a registered trademark of Dries Buytaert.