I've done a few searches on this and haven't come up with much.
I have a module which relies on a lot of specific CSS code. I'm currently adding the css to my default template, but would like to have some way of adding the css as part of the module installation so that when I polish it I can make it available to all and they won't need to hack their templates. I'm sure I've missed the obvious solution - any pointers greatly appreciated.
Best way to include module-specific css
-
- Forum Members
- Posts: 40
- Joined: Thu Jul 31, 2008 12:16 pm
-
- Forum Members
- Posts: 40
- Joined: Thu Jul 31, 2008 12:16 pm
Re: Best way to include module-specific css
Have a look at the Album module - it has it's own stylesheet.
Alternately, you could look at the code for adding a stylesheet (lib/classes/class.stylesheetoperations.inc.php I believe) and include it in your install, along with a post install message alerting the user to attach it to their template.
Nullig
Alternately, you could look at the code for adding a stylesheet (lib/classes/class.stylesheetoperations.inc.php I believe) and include it in your install, along with a post install message alerting the user to attach it to their template.
Nullig
Last edited by Nullig on Tue May 12, 2009 2:57 pm, edited 1 time in total.
-
- Forum Members
- Posts: 40
- Joined: Thu Jul 31, 2008 12:16 pm
Re: Best way to include module-specific css
Many thanks - that may just be the nudge in the right direction that I needed.
Re: Best way to include module-specific css
The best way is the proper way:
The proper way is include the stylesheet in the
What I would do is assign a variable inside a module template, turn process_whole_template false in cinfig, and if the variable exists include the stylesheet in the head section of the template.
This can avoid some problems. For example if you load a page and immediatelly click on a image on the album page and the stylesheet is not loaded(this count for scripts too), the CSS/Script, will not work if they're not cached.
Regards
G
The proper way is include the stylesheet in the
What I would do is assign a variable inside a module template, turn process_whole_template false in cinfig, and if the variable exists include the stylesheet in the head section of the template.
This can avoid some problems. For example if you load a page and immediatelly click on a image on the album page and the stylesheet is not loaded(this count for scripts too), the CSS/Script, will not work if they're not cached.
Regards
G
-
- Forum Members
- Posts: 40
- Joined: Thu Jul 31, 2008 12:16 pm
Re: Best way to include module-specific css
Thanks Viebig,
If I am understanding you correctly, your solution requires that the template is aware of the plugin. I'm looking for a solution that will work on anybody's template.
If I am understanding you correctly, your solution requires that the template is aware of the plugin. I'm looking for a solution that will work on anybody's template.