RE: [SMARTY] Using Smarty for Dynamic CSS
| From: | Sven Axelsson | Date: | Fri, 03 May 2002 13:43:21 +0000 |
| Subject: | RE: [SMARTY] Using Smarty for Dynamic CSS | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-4027@lists.php.net to get a copy of this message | ||
Or with a slightly different twist, this:
---- file: smarty/plugins/function.styleref.php
<?php
function smarty_function_styleref($params, &$smarty)
{
// Get the given section from all loaded config files.
// Given in another thread.
$stylesheet = $smarty->_conf_obj->get_all('stylesheet');
$browser = get_browser();
$style = $browser->browser == 'Netscape' ? 'ns' : 'def';
// Use other stylesheets for printing
$print = $_GET['print'] == 'yes' ? 'print_' : '';
$css = $stylesheet[$print . $style];
$charset = $stylesheet['charset'];
echo "<link rel=\"stylesheet\" href=\"$css\"
type=\"text/css\"
/>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=$charset\" />\n";
}
?>
---- file: global.conf
# Global definitions
doctype = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0
Transitional//EN\">"
[stylesheet]
charset = "iso-8859-1"
def = "/resources/bow.css"
ns = "/resources/bow_ns.css"
print_def = "/resources/bow_print.css"
print_ns = "/resources/bow_print_ns.css"
---- file: test.html
{load_config "global.conf"}
{#doctype#}
<html>
<head>
<title>Test</title>
{styleref}
</head>
...
/sven axelsson
> -----Original Message-----
> From: Alan McFarlane [mailto:amcfarlane@bigfoot.com]
> Sent: den 3 maj 2002 15:20
> To: mpn@3dgamelink.com; smarty-general@lists.php.net
> Subject: RE: [SMARTY] Using Smarty for Dynamic CSS
>
>
> Yup
>
> I use the following code:
>
> -- index.php --
> ...
> $tpl->assign("style", "default");
> ...
>
> -- index.tpl --
> ...
> <link rel="stylesheet" type="text/css"
> href="./styles/{$style}.css" />
> ...
>
>
> -----Original Message-----
> From: MPN [mailto:mpn@3dgamelink.com]
> Sent: 03 May 2002 04:02
> To: smarty-general@lists.php.net
> Subject: [SMARTY] Using Smarty for Dynamic CSS
>
>
> Has anyone explored the possibility of using smarty for
> dynamically changing CSS selectors?
>
> KT
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>