Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Best practices for external css files

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Wed Feb 13, 2008 9:26 pm    Post subject: Best practices for external css files Reply with quote

Well its getting to where I need a bit more flexibility with my stylesheets.

Currently I have this:

<!-- styles loop -->
{foreach from=$styles item='style'}
<link href="{$styleurl}/{$style.url}.css" rel="stylesheet" type="text/css" {if $style.media} media="{$style.media}" {/if}/>
{/foreach}

and I just load up an array of styles which is names and the media if any and feed it to smarty for rendering the page.

Now, however, I would like to actually have the style files be templates (in particular I would like to parameterize the site colors) and be able to have smarty variables and substitute values for them. However I would like to continue the practice of linking to external files and not include the styles right in the output. I was thinking of some scheme where I substitute the variables and use smarty fetch and write out temporary style files and then include them. But that seems messy and it incurs a lot of housecleaning. Is there perhaps some better way?

Also what are the security features of Smarty and why should I upgrade to .19 I just upgraded to .18 a week ago.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Feb 13, 2008 10:40 pm    Post subject: Reply with quote

You could change your style files into template files and then include them like this:

Code:
{foreach from=$styles item='style'}
{include file="$styleurl/`$style.url`.tpl"}
{/foreach}
Back to top
View user's profile Send private message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Thu Feb 14, 2008 12:42 am    Post subject: Reply with quote

Thanks but this is exactly what I don't want to do. because then the style file code would get pulled in and included in the output. I have good SEO rankings because I do not have a lot of javascript and styles at the beginning of my pages. I link to them externally and I indicated that I wished to continue doing so. Doing it like this pulls all the code in serverside, which is at least better than having a copy hard coded in each page but then all that code goes to the client and the client can't get the benefit of cacheing a style file he already used, and also the bots never get to your real content because they are grinding through the javascript code & styles.

I was thinking maybe there was a smarty plugin or something where it does all that housekeeping you would need to save style files with dynamic database provided values for colors etc, and maybe puts these temporary files in the server cache or something.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Feb 14, 2008 1:42 am    Post subject: Reply with quote

Okay, I understand.

But I see another problem. If you want to pass parameters by Smart to your style files the resulting file names must be unique for different parameter values. So this might be a quiet complex task....
Back to top
View user's profile Send private message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Thu Feb 14, 2008 2:15 am    Post subject: Reply with quote

now you are in the game. Smile yes there isthe issue of file names. and the other issue of cleaning up all the temporary stuff after you don't need it. Perhaps you could name them after the session and store them in the smarty cache. I just thought this is a general enough thing maybe someone has done it. If it were easy and obvious
I wouldn't be asking how to do it. Smile
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP