How to include custom CSS in module

Get help with installation and running official modules for phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
caramello
Posts: 70
Joined: Thu 23. Sep 2004, 21:43

How to include custom CSS in module

Post by caramello » Thu 19. Feb 2009, 11:37

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
A website is a concept not a digital brochure ! Vectrus Internet Solution

User avatar
update
Moderator
Posts: 6386
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: How to include custom CSS in module

Post by update » Thu 19. Feb 2009, 12:20

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 ;) )
It's mostly all about webdesign, logo design, new and old pages refresh, print BUT slowly switching to be supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.

caramello
Posts: 70
Joined: Thu 23. Sep 2004, 21:43

Re: How to include custom CSS in module

Post by caramello » Sat 21. Feb 2009, 14:20

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
A website is a concept not a digital brochure ! Vectrus Internet Solution

User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: How to include custom CSS in module

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

>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )

User avatar
update
Moderator
Posts: 6386
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: How to include custom CSS in module

Post by update » Sat 21. Feb 2009, 16:56

Uuooh - you are right... I didn't read that your question does deal with a module :oops:
It's mostly all about webdesign, logo design, new and old pages refresh, print BUT slowly switching to be supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.

breitsch
Posts: 473
Joined: Sun 6. Mar 2005, 23:12
Location: bern switzerland

Re: How to include custom CSS in module

Post by breitsch » Sat 21. Feb 2009, 18:12

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!
http://www.youtube.com/watch?v=jqxENMKaeCU
because it's important!
breitsch

User avatar
update
Moderator
Posts: 6386
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: How to include custom CSS in module

Post by update » Sat 21. Feb 2009, 19:16

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!
It's mostly all about webdesign, logo design, new and old pages refresh, print BUT slowly switching to be supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.

caramello
Posts: 70
Joined: Thu 23. Sep 2004, 21:43

Re: How to include custom CSS in module

Post by caramello » Tue 24. Feb 2009, 00:40

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. :-( => :-)
A website is a concept not a digital brochure ! Vectrus Internet Solution

Post Reply