Include FE custom CSS/JS in a module

To get css or js files included in the frontend output (in the head) of your module add them to your code like:

Forum: How to include custom CSS in module

Autor: breitsch
CMS-Version: >= V1.3.0


  • $phpwcms['allow_ext_init'] = 1;
  • $phpwcms['allow_ext_render'] = 1;
  • $phpwcms['allow_cntPHP_rt'] = 1;

// load js functions
$block['custom_htmlhead']['javascript.js'] = '  <script src="'.$phpwcms['modules'][$crow['acontent_module']]['dir'].'template/js/javascript.js" type="text/javascript"></script>';
  //load inline css
$block['custom_htmlhead']['inlinecss.css'] ='<style type="text/css">'.LF.'  .classname  {property:value;}'.LF.'</style>';
  //load external style sheet
$GLOBALS['block']['custom_htmlhead']['externalcss.css'] = LF.'  <style type="text/css">'.LF.'@import url("'.$phpwcms['modules'][$crow['acontent_module']]['dir'].'template/css/externalcss.css");'.LF.'</style>';

last key of the $block array must be unique!

Include BE custom JS in a module

$BE['HEADER'][] = getJavaScriptSourceLink('include/inc_js/optionselect.js');
english/technics/modules.txt · Last modified: 2018/06/03 18:09 (external edit) Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0