yes, it's the solution i have chosen. Thx !
Solved Using The Build Hook on Tpl Files That Are Inside Folders
-
Hey again. When trying to run the build hook on a template file that is inside a folder, it doesn't seem to be run.
I have the following structure for my example:
Root Folder: Template -
File 1: users.tpl -
Subfolder: Partials -
File 2: users_list.tplIf I was to use the following hooks:
{ "hook": "filter:users.build", "method": "usersBuild" }, { "hook": "filter:user_list.build", "method": "userListBuild" }
The first hook would be executed, but the second one would not.
Is there something I am missing / not understanding? -
Yes it's called
filter:middleware.render
Take a look here https://github.com/NodeBB/NodeBB/blob/master/src/middleware/render.js#L47-L51 -
users_list.tpl
is a partial so it is not directly rendered in nodebb core withres.render(templateName, data)
that's why the hook won't fire for it.What are you trying to do in
userListBuild
? You can probably do it in theusersBuild
hook by accessing the user data intemplateData.users
-
Alright, understood. I wasn't sure how it worked then it seems. Is there a 'global' build hook? Something that is fired on every page?
-
Yes it's called
filter:middleware.render
Take a look here https://github.com/NodeBB/NodeBB/blob/master/src/middleware/render.js#L47-L51 -
Beautiful. Thanks a bunch!