Skip to content

Instantly share code, notes, and snippets.

@croxton
Created October 1, 2012 10:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save croxton/3810681 to your computer and use it in GitHub Desktop.
Save croxton/3810681 to your computer and use it in GitHub Desktop.
Better Workflow > Assets integration
In ft.assets.php add this to the top of the pre_process function:
/**
* Pre Process
*/
function pre_process()
{
// -------------------------------------------
// Get the exp_assets_entries rows
// -------------------------------------------
// BWF support
$from_bwf = FALSE;
if (isset($this->EE->session->cache['ep_better_workflow'])
&& isset($this->EE->session->cache['ep_better_workflow']['preview_entry_data']))
{
$draft_data = unserialize($this->EE->session->cache['ep_better_workflow']['preview_entry_data']->draft_data);
if (isset($draft_data['field_id_' . $this->field_id]))
{
$draft_rows = $draft_data['field_id_' . $this->field_id];
// build an array Assets can work with
$rows = array();
foreach ($draft_rows as $key => $val)
{
if ( ! is_array($val))
{
$rows[$key] = array();
$rows[$key]['file_path'] = $val;
}
}
$from_bwf = TRUE;
}
}
if ( ! $from_bwf)
{
// the original if/else conditional goes in here
}
// -------------------------------------------
// Get the files
// -------------------------------------------
// the function continues here...
}
@iso100
Copy link

iso100 commented Nov 9, 2012

Which Assets version is this for? I added this code and got an error when publishing a draft.

@iso100
Copy link

iso100 commented Dec 6, 2012

What version of assets is this valid for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment