1
ksleong
Include CSS Style Sheet Inside A Template
  • 2007/9/18 12:19

  • ksleong

  • Just popping in

  • Posts: 1

  • Since: 2007/8/9 1


Hi,

Template files don't contain <head> tags. If I want to include a separate style sheet in a template file, how can I do that? Thanks!

Leo

2
kaotik
Re: Include CSS Style Sheet Inside A Template
  • 2007/9/18 12:29

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


Just put this at the top of your template:
<link rel="stylesheet" type="text/css" href="<{$xoops_url}>/modules/yourmodule/yourstylesheet.css" />

It will work fine.

Note:
If your building a new module to release here on xoops, I would recommend you use the .item class from the default theme whenever possible. That way your module will adapt to each users theme.

3
vaughan
Re: Include CSS Style Sheet Inside A Template
  • 2007/9/18 14:25

  • vaughan

  • Friend of XOOPS

  • Posts: 680

  • Since: 2005/11/26


if you are wanting a W3C valid template then adding

<link rel="stylesheet" type="text/css" href="<{$xoops_url}>/modules/yourmodule/yourstylesheet.css" />

will make the templates invalid.

you're better to use >

$xoTheme->addStylesheet(XOOPS_URL.'/modules/<modulename>/stylesheet.css');

place that code right after where it says

include XOOPS_ROOT_PATH . '/header.php';

in the php file itself. that will then inject the stylesheet into the <head> of the theme during parsing.

including the link in the template itself will also not work fully if you have module cache enabled too. so the $xoTheme method is best..