I am building a site for my school. Teachers will be able to upload their CVs. Their files will be PDFs and I need to have them in two languages (English and Greek). So I have a File field type with limited (2) allowed number of values.
It works alright, however I would like to control the filenames. Ideally I would like to use their email (username) value and add a suffix. Say if someone has the email 'firstname.lastname@example.org', it would be ideal to rename their 2 pdf into: 'myname_en.pdf' and 'myname_gr.pdf'.
So, no matter what filename they upload, I would like to rename it and save using the above mentioned filenames. I understand that this might be tricky, since the email might also being given at the same time (when creating new content of type 'staff'). However, email value is required (CV is not) so can I safely assume that I have the username portion of the email value? How can I get that substring and use it to 'create' my filenames?
I am not sure such a thing is possible, I guess it might be.
I tried to search around, but found no definite solution.
This thread seems relevant, however the chosen answer points to two other, also relevant threads.
The first one is quite old (May 2012), and has no chosen answer.
The second one is from 2014, and also has no chosen answer.
I couldn't find anything else ..
I 'm new to Drupal, being using it for a couple months. I 'm still fighting my way out of the Desert of Despair, so please show some understanding.
I feel fairly confident with twig and templates, but haven't really grasped the idea of pre-hook functions (?). I have a feeling this is a case where I need to use them ...
There is also mention of a relevant contrib module, specifically this: https://www.drupal.org/project/filefield_paths
However, it's still in beta version for D8, released in December 2015, and its development version hasn't been updated since March 2016.
I couldn't find any other info ..
Finally, perhaps I need to mention that I have changed the default directory for all uploaded CVs, they 're all kept under a non-time specific dir with a simple title, like 'Teachers-CVs'.
Thanks for your time - any help would be greatly appreciated...