When viewing a static resource (web context) in 2.8.2, only the content field renders. The rest of the template is ignored.
I noticed the issue when upgrading a site from 2.8.1 that relies on static resources.
As a quick fix, I have copied over modstaticresource.class.php from 2.8.1 and that works as expected.
Create an HTML file, create a static resource and link to the file. Be sure to use the new system settings resource_static_path or resource_static_allow_absolute. Assign a template that's not empty and has the [[*content]] tag specified.
Only the content field renders. The rest of the template isn't there.
If the [[*content]] tag is removed from the template, then the template renders fine (obviously without the content).
Template should render as normal with the static resource content being added via the [[*content]] tag.
Could be something to do with a change made here:
https://github.com/modxcms/revolution/pull/15656
MODX version 2.8.2
@Mark-H Could you please check?
It looks to be an issue here:
https://github.com/modxcms/revolution/blob/2.x/core/model/modx/modstaticresource.class.php#L199-L205
If the content is returned then so is the template, fixing the issue:
// Output the content, either streaming with readfile() or by echo'ing content that was retrieved earlier from media source
if ($streamable) {
if (!$contentType->get('binary')){
return file_get_contents($file);
} else {
readfile($content);
}
}
else {
echo $content;
}
I'm not sure if that's the best way to handle it (pretty sure it's not since it's still considered streamable) but happy to do a PR if so.
Hi @muzzwood , I tested your solution and it seems working, thanks,
I didn't check eventually problems with the rest of the new code
Welp, I didn't know that was a way static resources could be used so that's a meatball i must've thrown out of the bowl of spaghetti this code was. 馃槀
This issue has been mentioned on MODX Community. There might be relevant details there:
https://community.modx.com/t/modx-2-8-2-tag-not-rendered-in-static-resources/3985/4