Open olinox14 opened 3 years ago
Since this ViewHelper is designed for frontend usage, it is not sensible to remove the display restrictions (neither hidden nor others). The right solution is actually the workaround you already came up with - passing the record so the ViewHelper does not attempt to load it. In fact this is also recommended practice in frontend for any use case where you have access to the page/content record (Flux will attempt to insert this into template variables but non-Flux usage may not have access to the record). This is also better for performance since you don't cause an unnecessary SQL query (actually, one additional query per relation).
I use this VH in the backend to display a preview of the carousel images, shouldn't I? I agree on the fact that it's obviously better to directly pass the record, however I don't think that the sole fact of passing the uid as parameter should be able to crash the backend because of an hidden content... The exception could be catch and managed in the viewhelper, or as I said, the restrictions could be lifted?
Issue: an exception
No record was found. The "record" or "uid" argument must be specified.
is thrown when using FalViewHelper within an hidden content.To reproduce, create a template:
Then, add a content of this type to a page in the Typo3 Backend, and hide this content.
An exception is thrown, because the
FluidTYPO3\Vhs\ViewHelpers\Resource\Record\AbstractRecordResourceViewHelper->getRecord()
can not find any matching record (default restrictions apply to querybuilder here)A quick workaround is to replace:
{v:content.resources.fal(field: 'images', uid: '{record.uid}')}
By{v:content.resources.fal(field: 'images', record: '{record}')}
However, this remains a bug, and I suggest to remove the 'HiddenRestriction' from the querybuilder in the getRecord() method. Maybe StartTimeRestriction and EndTimeRestriction shall be removed too.