Lower hook priority#2
Conversation
Hi Wanze, I'm not sure if this will fix the problem, but I've noticed some other modules that add markup using a hook have to raise their hook's priority to make sure their hook has a higher priority. I ran into this problem with Tracy Debugger and https://github.com/madebymats/FieldtypeLeafletMapMarker. Tracy Debugger is fixed now by raising it priority really high. I have a pull request FriendsOfProcessWire/FieldtypeLeafletMapMarker#9 to fix it for FieldtypeLeafletMapMarker, but should all other modules have to do this? Can TemplateEngineFactory lower it's priority so other modules won't have to raise their priority? Here's what it looks like on my site:
|
@gmclelland Thanks for your pull request. Does it work on your environment if you decrease the priority to 99? I had a similar problem with this module in combination with ProCache. Setting the priority to less than 100 didn't work because If it works, I'm happy to merge, otherwise we need another solution. Cheers |
Updated the priority. Works for me.
|
HI @wanze, I updated the Pull Request to 100.01 which should be safe and works in my testing. What your thoughts on this? Does it look ok to you? |
|
@gmclelland Thank you, looks good. Actually I'm surprised that you can pass "float strings" as priority, I think the description should be updated ;-) Could you open another pull request targeting the dev branch of this repository? I will merge the PR, do some tests, update version number and merge into master. Thanks again :) |

Hi Wanze,
I'm not sure if this will fix the problem, but I've noticed some other modules that add markup using a Page::render hook have to raise their hook's priority above TemplateEngineFactory's priority to make sure their hook has a higher priority.
I believe in both cases the modules were outputting html right before the closing body tag using the Page::render hook.
I ran into this problem with Tracy Debugger and https://github.com/madebymats/FieldtypeLeafletMapMarker.
Tracy Debugger is fixed now by raising it's hook priority really high. I have a pull request FriendsOfProcessWire/FieldtypeLeafletMapMarker#9 to fix it for FieldtypeLeafletMapMarker, but should all other modules have to do this? Can TemplateEngineFactory lower it's priority so other modules won't have to raise their priority?
Here's what it looks like on my site:

Notice how the MarkupAddInlineScript module (100.1) runs before TemplateEngineTwig (100.3)? In this case the Leaflet initialization javascript markup doesn't get added before the closing body tag.
The only thing I'm not sure of is if it is ok to go under 100 which is the default priority?
Maybe this module should set it to 100.1? I'm not sure. Maybe you know more about this?