https://github.com/beechit/default_upload_folder
TYPO3 extension to configure different default upload folders
https://github.com/beechit/default_upload_folder
Last synced: 8 months ago
JSON representation
TYPO3 extension to configure different default upload folders
- Host: GitHub
- URL: https://github.com/beechit/default_upload_folder
- Owner: beechit
- Created: 2016-04-06T12:14:02.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-06-06T19:34:49.000Z (about 2 years ago)
- Last Synced: 2024-08-10T23:18:07.839Z (almost 2 years ago)
- Language: PHP
- Homepage:
- Size: 72.3 KB
- Stars: 10
- Watchers: 8
- Forks: 20
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Default upload folder
=====================
Make it possible to configure the default upload folder for a certain TCA column
**How to use:**
1. Download from TER or require (`composer require beechit/default-upload-folder`) extension default_upload_folder
2. Install extension default_upload_folder via the extension manager
3. Create the default folders or the folder is automatically created *(Editors needs access to storage and the folder
root)*
4. Add configuration to pageTs
```
default_upload_folders {
# folder can be a combined identifier
tx_news_domain_model_news = 1:news
# Or a folder relative to the default upload folder of the user
tx_news_domain_model_news = news
# You can set a folder for the whole table or for a specific field of that table
tx_news_domain_model_news.fal_related_files = news_downloads
tx_news_domain_model_news.fal_media = news_media
# You can set a fallback for all tables
defaultForAllTables = 1:myDefaultUploadFolderForThisPartOfTheTree
# You can set a default year/month/day folder within the set default folder
tx_news_domain_model_news.dateformat = 1
tx_news_domain_model_news = 1:news/{Y}/{m}
}
```
**FAQ**
_What happens when the editor does not have access to the upload folder?_
> The "Select & upload files" and "Add media by URL" buttons are not available for the editor
_How do the fallbacks work?_
> 1. First it will check if there is a default upload folder for the table & field combination.
> 2. Then it will check if there is a default upload folder for the table.
> 3. Finally, it will check if there is configuration for `defaultForAllTables`
_Are folders automatically created?_
> Yes, but only if path set with combined identifiers like 1:myNewsPicturesFolder
_How to use the year/month/week/day feature?_
> 1. Make sure the variable `tx_mews_domain_model_news` has the `dateformat` value set to `1`.
> 2. Then (over)write the original variable however you prefer: `tx_news_domain_model_news = 1:news/{Y}/{m}`
> 3. This will translate into: `1:news/2023/06` which in turn creates the directory: `news/2023/06`
_Why does the year/month/week/day feature not use the php strftime function & format?_
> The strftime function has been deprecated in PHP 8.1, and will
> be [removed in PHP 9.](https://www.php.net/manual/en/function.strftime.php)
>
> Currently, there is no proper solution that takes localisation in consideration. Hence, the choice to create a custom
> interpreter.
> The values used are based on the [date() -> Parameter Values](https://www.w3schools.com/php/func_date_date.asp)
> format.
> the values currently in use are:
> - Y - A four digit representation of a year
> - y - A two digit representation of a year
> - m - A numeric representation of a month (from 01 to 12)
> - n - A numeric representation of a month, without leading zeros (1 to 12)
> - d - The day of the month (from 01 to 31)
> - j - The day of the month without leading zeros (1 to 31)
> - W - The ISO-8601 week number of year (weeks starting on Monday)
> - w - A numeric representation of the day (0 for Sunday, 6 for Saturday)
>
> The other values are currently **not** in use.
>
> This functionality might be refactored in the future when php offers a proper replacement to the removal
> of `strftime`.
**Requirements:**
> TYPO3 V12.4
**Changes TYPO3 V12:**
>Converted from Hook to Event, as Hooks are depricated.
>
> Specifically: https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Events/Events/Core/Resource/AfterDefaultUploadFolderWasResolvedEvent.html
>
> Added Services.yaml (as required for Event handling)
> Now receives $backendUserAuthentication directly from $GLOBALS['BE_USER'].