ElkArte Community

Elk Development => Theme development => Topic started by: Wizard on August 28, 2015, 09:43:28 am

Title: Adding custom style sheets
Post by: Wizard on August 28, 2015, 09:43:28 am
How to add custom style sheets to new theme ? Should I add it to index.template.php ? An example can help a lot.
Title: Re: Adding custom style sheets
Post by: CrimeS on August 28, 2015, 10:49:44 am
Yup, add it to the head section in index.template.php. For example before </head>
Code: [Select]
<link rel="stylesheet" type="text/css" href="mystyle.css">
Title: Re: Adding custom style sheets
Post by: emanuele on August 28, 2015, 02:34:26 pm
Another way is to use loadCSSFile in the template_init function.
Title: Re: Adding custom style sheets
Post by: Joshua Dickerson on August 28, 2015, 02:48:03 pm
Quote from: emanuele – Another way is to use loadCSSFile in the template_init function.
The better way so it can compact/minimize and you can keep track of what's loaded using the debugging tools.
Title: Re: Adding custom style sheets
Post by: emanuele on August 28, 2015, 02:52:49 pm
And, you can even decide in which template load it, because you can just create a "template_NameOfTheTemplate" function and that is called automatically just after the file has been included (i.e. just after the call "loadTemplate('NameOfTheTemplate')").
Title: Re: Adding custom style sheets
Post by: CrimeS on August 28, 2015, 03:39:15 pm
Well @emanuele always has a nice approach :D
Title: Re: Adding custom style sheets
Post by: emanuele on August 28, 2015, 05:17:17 pm
LOL

That's the result of messing with the code: you discover things that only very few people know. :P
Title: Re: Adding custom style sheets
Post by: anagnam on October 17, 2015, 05:02:44 am
@emanuele
Quote from: emanuele – Another way is to use loadCSSFile in the template_init function.

care to post an example? sorry newbie here thanks
Title: Re: Adding custom style sheets
Post by: emanuele on October 17, 2015, 08:44:56 am
http://www.elkarte.net/community/index.php?topic=2998.msg20906#msg20906

;)