I am making a custom template for the ‘File Links’ element.
In it I want to disable download of some of the files until the frontend user has logged in.
So my problem is the Access tab with the Frontend Usergroup field is not availble on the file objects.
How do I add the access tab?
I have tried making sys_file_metadata.php
with:
TYPO3CMSCoreUtilityExtensionManagementUtility::addToAllTCAtypes('sys_file_metadata', 'access','', 'after:title');
Essentially, I want to show a list of all links, but depending on the usergroup some will link to the login page instead of the download.
Edit:
I can add the user groups field manually like this:
$newFields = [
'fe_groups' => [
'label' => 'Usergroup Access',
'exclude' => true,
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'size' => 5,
'maxitems' => 20,
'foreign_table' => 'fe_groups',
]
],
];
TYPO3CMSCoreUtilityExtensionManagementUtility::addTCAcolumns('sys_file_metadata', $newFields);
TYPO3CMSCoreUtilityExtensionManagementUtility::addToAllTCAtypes(
'sys_file_metadata',
'fe_groups',
'',
'after:title'
);
However, the only problem is that it does not show up when you debug the template?
2
Answers
Turned out to be very simple. To find available properties I was using:
<f:debug>{_all}</f:debug>
However this was giving me a shortened list of properties. So when I used
<f:debug>{file.properties}</f:debug>
it expanded that list to include the value I was looking for:fe_groups
Your problem might not only be the "Access"-tab… FAL does not support FE-groups-handling so far. So only getting the field displayed in the backend will not mean, these are applied, too.
If you really like to protect files, have a look at one of these extensions:
If your use-case only needs a different display and not hard restrictions, maybe you can work with File collections