ExpressionEngine 2024 Quarter 1 Review Quarter 1 Review
Am hoping to use an extension that hooks into the after_file_update
hook to add an alert to the Files / Edit File panel.
The documented method for adding an alert fails. The code I am using within the extension to generate the alert looks like this:
ee('CP/Alert')->makeInline('shared-form')
->asIssue()
->withTitle(lang('some_title'))
->addToBody(lang('some_title_desc'))
->defer();
Have confirmed that this code does indeed generate an alert within EE.
I have used the title shared-form
for the alert (i.e. ee('CP/Alert')->makeInline('shared-form')
) since that seems to be what EE uses almost always internally) but it seems not to make any difference what title I use (nor indeed is it clear what purpose the title actually has).
I have traced processing of this using a php debugger and can confirm that the code is processed correctly and a suitable element added to the EE Session variable used to accummulate alerts.
However the Files / Edit Data panel always generates an alert after a save (to notify either success or failure) and when this second alert is generated when the existing session data is read it always is read as being blank, so my form is ‘lost’ and the only form that appears is the one generated by the Files / Edit Data panel.
I am unsure whether this is a bug, or there is some undocumented hoopla I need to follow through to prevent the alert that is created from being lost before the Files / Edit Data success alert is generated.
I would value any thoughts / guidance on what I should do to resolve this.
EE7.2.15 / php 8.1.16
Hello, I think you can use a different hook that is triggered after the default alert is generated. You can try using the sessions_end hook, which is triggered at the end of the session initialization process. This hook is triggered after the default alert is generated, so you can add your custom alert without it being overwritten.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.