solved Delete file listener

SteveX
SteveX
@ultrajam
5 days ago
2,587 posts
Hi Team, hope you are all well and happy!

I'm trying to delete data for an uploaded file in a custom module's file field which allows multiple files.

In a module item update form it lists the files and you can click the x button of a file to delete it.

When I click the x the correct file is deleted by the core delete view.

I have a listener for that core delete view but I can't see how to know which file is being deleted:
jrCore_register_event_listener('jrCore', 'module_view', 'ujRag_file_delete_listener');

function ujRag_file_delete_listener($_data, $_user, $_conf, $_args, $event)
{
if ($_data['_2'] == 'rag_docs' && $_data['module'] == 'jrCore' && $_data['option'] == 'delete') {
fdebug("okokok");
global $_post;
fdebug("_post",$_post,$_data, $_args, $event);
}
}


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 04/22/25 03:00:50AM
SteveX
SteveX
@ultrajam
5 days ago
2,587 posts
Also, is there any way to keep uploaded files when adding another in the update form? I can remove one of multiple files, but if I try to add another file the existing files are deleted.

Edit: I've found the $_existing array that can be passed into jrCore_save_all_media_files, so this part is solved.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 04/22/25 01:21:39AM
SteveX
SteveX
@ultrajam
5 days ago
2,587 posts
I can see how to do this now, marking as solved :)


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

Tags