Re: [SMARTY] Using Smarty for Dynamic CSS

From: Date: Fri, 03 May 2002 14:54:02 +0000
Subject: Re: [SMARTY] Using Smarty for Dynamic CSS
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4033@lists.php.net to get a copy of this message
In our experience, we found that trying to make style sheets dynamic with Smarty ended up being overkill. We just include static .css files and keep them maintained just like any smarty .tpl file. Monte Sven Axelsson wrote:
Isn't the whole point with CSS that you don't change the style selectors, you change the style definitions? Of course you can do it like you say below, but wouldn't it be better to dynamically generate the definitions like: <style> {$p_news} {$p_whatever} </style> and just use the selectors directly in your html? /sven axelsson
-----Original Message----- From: MPN [mailto:mpn@3dgamelink.com] Sent: den 3 maj 2002 16:34 To: smarty-general@lists.php.net Subject: RE: [SMARTY] Using Smarty for Dynamic CSS Thanks for the replies. :) I was thinking more along the lines of changing selectors within the body of the template. Say for instance, you give the user the option to change paragraph text size, and somewhere in your CSS you have something like p.news1 {text-size: 1.0em; }... p.news5 {text-size: 1.5em; }. Then based on the user selection, the appropriate class selector is inserted into the template either by comparing a list of possible values from a config file, or by passing the variable directly to the template. Example: <p.{$paraopt}>Blah blah</p> {* This assumes the entire selector is passed *} OR <p.{#$paraopt#}>Blah blah</p> {* Where $paraopt is a simple identifier (a1, a2, ...) and the config file holds the actual CSS selector choices (news1, news2...) *} So the question is, what would be more efficient in terms of performance and code?? KT -----Original Message----- From: Alan McFarlane [mailto:amcfarlane@bigfoot.com] Sent: Friday, May 03, 2002 6:20 AM 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 -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

« previous php.smarty.general (#4033) next »