Page 1 of 1

How to include custom CSS in module

Posted: Thu 19. Feb 2009, 11:37
by caramello
High!

Does anybody know how to include a module specific style sheet in a module. For use with the front end templates.

Example,

I have a module that shows information from PHPWCSM, but i want to include a stylesheet relevant to the templates of that module.

So i make a css folder in my module/template directory, add a css file, but ghow do i include them in my template properly (= according to O.G.'s way of scripting)

please advise.

Julius

Re: How to include custom CSS in module

Posted: Thu 19. Feb 2009, 12:20
by update
Put something like the following into your template:

Code: Select all

[PHP]
	$GLOBALS['block']['css']['reg_tabs_accordion01_login'] = 'specific/reg_tabs_accordion01_login.css';
[/PHP]
In this example the css file is living in /template/inc_css/specific/
I think that this should work for you also (like it's working for me ;) )

Re: How to include custom CSS in module

Posted: Sat 21. Feb 2009, 14:20
by caramello
That would work for normal tempates, in normal content parts. Not in module templates. I f you would do that in a module, you would always end up placing the css file in the normal template/inc_css directory. I would like to NOT touch the phpwcms core in the module but rather include the css file in the modules template directory. like in :

/include/inc_module/mod_fe_userdetails/templates/css/style.css


Julius

Re: How to include custom CSS in module

Posted: Sat 21. Feb 2009, 14:37
by flip-flop

Re: How to include custom CSS in module

Posted: Sat 21. Feb 2009, 16:56
by update
Uuooh - you are right... I didn't read that your question does deal with a module :oops:

Re: How to include custom CSS in module

Posted: Sat 21. Feb 2009, 18:12
by breitsch
Claus you were close.
to get css or js files included in the frontend output (in the head) of your module add them to your code like:

Code: Select all

  // 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!

Re: How to include custom CSS in module

Posted: Sat 21. Feb 2009, 19:16
by update
That's great! I've been looking for that for days now for my forum integration (fiddled together some workaround by now) - will check it out! Thanks!

Re: How to include custom CSS in module

Posted: Tue 24. Feb 2009, 00:40
by caramello
S H I ....

I didn't see this. VERY nice.

I didn't see it because of the work on mod_userdetails, but now i see it, so now i am still not done with the module. :-( => :-)