3

I have written a custom field type which will allow users to upload a file (CSV). Upon submitting the file, the plugin needs to be able to read through it and then do its own thing (update database values).

There doesn't seem to be any code called on Joomla's end for custom field types, though. I have seen Components do similar things to what I'm doing, but Components have much more control over the backend. Is there any way for me to access the $_POST/$_FILES globals after the user uploads a file via custom field types?

To clarify, my problem isn't allowing the user to upload the file. It's being able to access it (no code is called after the user hits save). I have tried creating my own form within the field, but that doesn't work.

Joomla's documentation for this kind of thing is very lacking, and any help would be appreciated.

1

After some thinking, I came up with a pretty gross workaround.

The user must upload a file to Joomla and then a field is used to select which file. This was easy enough and straightforward. The only downside is that you'd have to check its contents during every plugin run.

A simple fix is to only check the file when the settings are updated: A hidden param (custom field type) is set to the current unit timestamp, which is then saved whenever the plugin settings are saved. The plugin stores in its cache the last time it dumped the cache. When it loads, it checks if the cached value is less than the parameter value. If so, the system will clear its cache and go about doing its business.

This can be expanded to do a lot more stuff that extensions are left in the dark for (eg: whenever the settings change).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.