Best practice to update data when a new fileversion has been uploaded?

Hi
I have a list of appartments stored in a structured field.
To import that list to the structured field I use an excelfile.
For now I have to reload the frontend-page to run a function which checks if the excelfile is newer than then content file. if yes, then it updates the content file.
But in my opinion this is a not an elegant solution, I excpect more automatisation.

Is there a way to call the update function automatically when a new fileversion has been uploaded (by a ftp-client) or are there other possibility available by kirby?
Or is it better to excecute the check-function by a specific timeinterval?

Kind regards
Alain

If you upload this Excel-File via FTP, then Kirby doesn’t know anything about your file, and you would have to use a cron job that does the check at regular intervals.

The alternative would be to upload the file via the Panel, in which case you could use Kirby’s hooks, or via some script that then triggers the hook.

Cronejobs are a server site thing, right?
PHP itself doesn’t allow running functions in a timeinterval?

Yes.

Poormanscron option in this plugin: GitHub - bvdputte/kirby-queue: A simple queue utility plugin for Kirby 3

PHP extension: PHP: Introduction - Manual

Interesting.
I guess when I run the function every second then I would not overload the server, right? :slight_smile:
The list size is only a few KBs.

What I wonder is why you update a structure field when you could read the data directly from the excel file?

Because this way then users can update the list via the panel in a more convenient/userfriendly way. Uploading the list via excel file (ftp-client) is ment for inhouse purposes.

Or is there a panel-page-reload hook?
I did not find any.
This way I could just reload the panelpage to reload the data from the excelfile.

Or is it possible to create a button in the panel to excecute reading from the excelfile?

Yes, that would be possible. You could also use the Janitor plugin which provides a button that can do all sorts of custom jobs in addition to some built-in stuff.