While developing a couple of extensions lately I figured out that a lot of extensions do not currently support quicksave including a lot of my own, so I tried to figure out why.
Turns out that the submit_new_entry_end hook doesn’t get fired when you quicksave. I figured out a way around this and wrote up the guide below for creating CP tabs:
ExpressionEngine hook processing:
General Notes:
Quicksaves do not fire submit_new_entry_end and because of this the hook should manually be called in the publish_form_start hook but only when $which == “save”.
Although submit_new_entry_end provides a $data array as a parameter; always use the $_POST array for custom tab data as the hook is called manually on quicksaves (see above). If you need to use processed EE entry data pull it from the DB using the entry_id.
Always assume that the data when it reaches the tab content is in the $_POST array. Previews, revisions and now NSM Publish Plus all provide data in the original format it was posted.
Quicksaving new entries does not set $_POST[‘entry_id’] or $_GET[‘entry_id’].
ExpressionEngine’s hook processing order is listed below (with hints) for each of the publish form actions.
↳ Green hooks are manual method calls in the previous hook; not fired by ExpressionEngine - Purple line are actions that need to be taken
New Entry:
Globals:
$IN->GBL(‘entry_id’) == FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
publish_form_start $which == “new” $entry_id = FALSE publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Edit Existing Entry:
Globals:
$IN->GBL(‘entry_id’) != FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
publish_form_start $which == “edit” $entry_id != FALSE publish_form_new_tabs publish_form_entry_data [color=purple]- Convert the db data to $_POST data publish_form_new_tabs_block - Process tab data from $_POST
Preview New Entry:
Globals:
$IN->GBL(‘entry_id’) == FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
publish_form_start $which == “preview” $entry_id = FALSE publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Preview Existing Entry:
Globals:
$IN->GBL(‘entry_id’) != FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
publish_form_start $which == “preview” $entry_id != FALSE publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Successful Quicksave New Entry:
Globals:
$IN->GBL(‘entry_id’) == FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
submit_new_entry_start publish_form_start $which == “save” $entry_id != FALSE publish_form_start ↳ Manually call: submit_new_entry_end - Process tab data from $_POST not the $data param publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Unsuccessful Quicksave New Entry:
Globals:
$IN->GBL(‘entry_id’) == FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
submit_new_entry_start publish_form_start $which == “preview” $entry_id = FALSE publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Successful Quicksave Existing Entry:
Globals:
$IN->GBL(‘entry_id’) != FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
submit_new_entry_start publish_form_start $which == “save” $entry_id != FALSE publish_form_start ↳ Manually call: submit_new_entry_end - Process tab data from $_POST not the $data param publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Unsuccessful Quicksave Existing Entry:
Globals:
$IN->GBL(‘entry_id’) != FALSE $IN->GBL(‘version_id’, ‘GET’) == FALSE
Hooks:
submit_new_entry_start publish_form_start $which == “preview” $entry_id != FALSE publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Load revision of existing entry:
Globals:
$IN->GBL(‘entry_id’) != FALSE $IN->GBL(‘version_id’, ‘GET’) != FALSE
Hooks:
publish_form_start $which == “edit” $entry_id != FALSE publish_form_new_tabs publish_form_new_tabs_block - Process tab data from $_POST
Leevi,
I am not very good at the EE extensions, and I need to create an extension that creates a tab on the publish form.
My biggest problem is trying to create that tab and at this point just printing ‘hello world’ when the tab is clicked on.
Do you know of a place that has a skeleton publish form tab extension? I can’t find an extension that is simple enough for me to dissect and figure it out, and thus change to suit my purposes.
Any help would be appreciated.
Thanks,
Kelley
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.