From: Alain F. <al...@va...> - 2001-03-29 17:46:25
|
Hi, [several parts of your original mail snipped away for better readability] > > 4. One should be able to define more than one theme. This means > that we'd > > need a "themes" table, and a "themesdetail" table that defines > the values > > for the individual styles, per theme. > > Eh? One will be able to have as many themes as he/she wants, right? Ah, I > should think a minute longer, before starting to write... If we > have dynamic > CSS, we nedd to have the values in the database, and in that database we > would need an entry for each value/theme pair. Did I get you right? Yes, that is exactly what I meant. That means that we basically need two tables? Well, the .CSS file I have in mind would look like this: .bigTitle { font-face: {bigTitleFontFace}; color: {bigTitleColor}; ... } Typical SQL query to build the CSS file: select theme_detail.StyleName, theme_detail.StyleValue from themes, themes_detail where themes.ThemeID = theme_detail.refThemeID AND themes.ThemeID = 1 Return: rowset containing two rows whose contents would be, for instance: StyleName -- StyleValue ================================ bigTitleFontFace -- Arial bigTitleColor -- black and so on. These would then be injected into Smarty, using assign(). Actually, as you can use arrays as parameters to assign(), you could easily assign the complete reurned recordset to Smarty: $Smarty->Assign($arrStyles), $arrStyles being constructed like this: $arrStyles = array(); while($row = mysql_fetch_row($rs) ) { array_push( $arrStyles[$row[0]] , $row[1] ); } Right ? :) If I'm not wrong, this will give us an associative array, like for instance: $arrStyles['bigTitleFontFace'] == "Arial" $arrStyles['bigTitleColor'] == "black" And that's what Smarty likes pretty well to do its job... :) > We should limit the customizable things to some set of options we define. > Full Stop. If needed, the user/admin can edit the stylesheet template > directly. I agree. That will keep the idea in the "possible to implement" category of developments :). > If we take the stylesheet template approach I layed out above, > and we decide > for using Smarty the cacheing/compiling would be done through > those. Nothing > to worry about :-) True ! > The abilty to choose a theme is enough, I would say. No nedd to give every > user the ability to customize the freely selectable theme even > more, right? > And I would suspect this to introduce (some) performance issues. Yes, that will definitely introduce performance issues... except if we would use dynamic templates. Let me explain: Every user, as soon as he creates his account, has his "own" templated CSS file that is included whenever he logs in. So instead of having one Smarty template called "styles.tpl.php", we would have many, created as soon as the user logs in: styles-<userID>.tpl. For instance: styles-valain.tpl, styles-godzilla.tpl, and so on. There will basically not be much overhead. What needs to be done? 1. Create the styles-<userID>.tpl template file when a new user account is created. This file would simply be a copy of the "stock" styles template, to have something to start with. Or, we could ask the user to select among several available pre-made styles. 2. Let Smarty handle the rest. Instead of writing Smarty->fetch("styles.tpl"), we'd use Smarty->fetch($userstyle) where $userstyle is, for instance, styles-valain.tpl, that is, dynamically built: $userstyle = "styles." . $UserID . ".tpl"; Smarty's handling of compiling and caching would do the rest, basically. Got the idea ? That's basically "user-customizable templates".. :) > > Satisfied? :-) Of course. You ? :) Greetings, Alain |