Inject modules HTML/JS/CSS codes in whole shop frontend


#1

Is there a way to add HTML/JS/CSS based on module frontend template in any shop FE-Page without edit the theme templates (e.g. without inserting blocks into theme templates)?


#2

Maybe i don’t understand, but why not use the existing blocks?


#3

The module ressource injection should work without any problems / template dependencies. The best approach would be, that the shop administrator don’t need to edit the template at all. Maybe I’m wrong, but if we use “existings blocks” it’s not sure that the block we used is present in the template, right? I think about a situation were the shop administrator is using a custom theme. So, we can’t be sure that the “Block” we used is available inside this custom theme template, right?


#4

Yes you’re right, but most custom themes are based on azure or flow, so blocks should be available also in custom themes. Also most modules use those default blocks, so if you make a theme without them, most of the modules available will not work. For troubleshooting, in backend service/system health you can see the blocks that are used by modules but not available in template and might cause problems.


#5

I can second that: Every child theme or even themes made from scratch shall definitely use all blocks. If a block is missing that is needed for a module on a specific place, please send a pull request.


#6

Ok so I guess there is no functionality to inject FE ressources into all pages without using Block / Themes / Templating?


#7

You could override method process in core/output to parse and change output, eg. look for /body and inject something before it.


#8

this way is not completely independent from templates, but you can add custom js files and scripts to the processing array for [{oxscript}], which has to be called from template.
here is an example: https://github.com/vanilla-thunder/bla-tinymce/blob/master/copy_this/modules/bla/bla-tinymce/application/core/blatinymceoxviewconfig.php#L199-L215