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 »

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: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: How to include custom CSS in module

Post 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 ;) )
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
caramello
Posts: 70
Joined: Thu 23. Sep 2004, 21:43

Re: How to include custom CSS in module

Post 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
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 »

>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: How to include custom CSS in module

Post by update »

Uuooh - you are right... I didn't read that your question does deal with a module :oops:
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
breitsch
Posts: 473
Joined: Sun 6. Mar 2005, 23:12
Location: bern switzerland

Re: How to include custom CSS in module

Post 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!
http://www.youtube.com/watch?v=jqxENMKaeCU
because it's important!
breitsch
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: How to include custom CSS in module

Post 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!
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
caramello
Posts: 70
Joined: Thu 23. Sep 2004, 21:43

Re: How to include custom CSS in module

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