modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.35k stars 528 forks source link

Static resources assigned certain types of templates fail to output a binary static file #16533

Open SnowCreative opened 4 months ago

SnowCreative commented 4 months ago

Bug report

Summary

Not sure if this a bug or a feature request, but the way binary static resources are currently processed is non-intuitive.

Step to reproduce

Create a static resource of any binary type (say, PDF) and assign a template that either has no content, or else has an un-cached content field ( like [[!*content]] or a custom snippet that processes content like [[!contentsnippet]] ). Link to the static file and save the resource.

Observed behavior

The linked file will not load on the front end if it's a PDF, and if it's a downloadable binary file, a file with empty content will be downloaded.

Expected behavior

Since binary static resources only load external files, and are not rendering any content needing a template, they should ignore the assigned template completely and output the linked file regardless of assigned template.

If someone makes a static resource, it’s going to be assigned whatever the default template is. If that template has a non-cached content field or snippet, the output is going to be broken, and they won't know why. The expectation is that there shouldn't be a need to change templates, because the resource is just going to output the linked file if it's binary, right?

It's desirable to use a custom template for binary static resources so that form customization can be applied to them, since the only fields really needed are the title and content fields. When I set one up like this, I assumed I could leave the template empty since nothing was going to get rendered using a template. It took a few hours of hair-pulling and a post about this on the support boards to figure out what the problem was.

Environment

Tested in MODX 3.0.4, but this probably applies to all versions.

modxcommunity commented 4 months ago

This issue has been mentioned on MODX Community. There might be relevant details there:

https://community.modx.com/t/binary-static-resources-not-downloading/7555/15