Why put your stylesheets in a template group?
Posted: 04 September 2008 09:36 AM   [ Ignore ]  
Grad Student
Rank
Total Posts:  52
Joined  01-10-2008

Hello,
I see from the basic intall of EE that it suggests you put your stylesheet in a template group. Can anyone tell me why you would do this and not just leave it loose on the server? E.g.
Why this

<link rel="stylesheet" href="{stylesheet=site/general_styles}" media="screen" />


instead of this

<link rel="stylesheet" href="http://domainname.com/styles/general_styles.css" media="screen" />

The reason I’ve been doing the latter, is because (I save my templates as files and edit them with a text editor) and I can still have my file as a .css file and so when I edit it in my text editor it has the proper highlighting.  If I put it in a template group it is a .php file and is difficult to read.  It also means I can use it with local test files as well as on the server.

Apart from the tidiness of keeping all the files organised in the same way/inside EE template groups, what are the advantages of putting your css in there?

Thanks!

 Signature 

http://www.gradualism.co.uk/

Profile
 
 
Posted: 04 September 2008 11:20 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  123
Joined  07-09-2008

It totally fine either way. Some people like it being in the EE control panel so if they are out of town or away from there office, they can make changes to the css file via an internet browser. I personally keep my style sheets out of EE, but that is just me.

 Signature 

http://www.unleashedideas.com

Profile
 
 
Posted: 04 September 2008 11:33 AM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

One plus is that if you use the {path=”“} variable to place your stylesheet then you can use variables from within your css file which may or may not help you out in certain cases.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 04 September 2008 03:32 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  381
Joined  03-01-2006

It also means you can use conditionals too which could be useful in some circumstances (having said that, I’ve never actually bothered - I always store mine in a separate folder on the server).

 Signature 

John Faulds - Tyssen Design | Member of EE Pro Network

Profile
 
 
Posted: 05 September 2008 03:03 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  91
Joined  07-04-2007

Mark, if you use the path variable to place the stylesheet, doesn’t this mean that it won’t get cached by the browser and will be dynamically regenerated with each pageview?

Maybe I got the wrong end of the stick but I’ve avoided using dynamic css for that reason and instead put any dynamic styles in-page with the <style> tag.

Profile
 
 
Posted: 05 September 2008 03:13 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

HIya,

Yep that is one slight side-effect but most browsers will cache a css file anyway and if you write good CSS then it should be pretty compact anyway.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 September 2008 07:43 AM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1644
Joined  05-13-2004

I like using global variables in the CSS file for my image path - very easy to update when I go from my local server to the live site.

 Signature 

CreateSean - My journey to pro web designer
currently improving my CSS, XHTML, JQuery & photoshop kung fu skills
I am the poster formally known as The Linguist.

Profile
 
 
Posted: 05 September 2008 06:44 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  606
Joined  03-02-2008

If you use the caching in a smart way (say every hour), there’s no reason an EE-generated CSS page (or Javascript) shouldn’t be a great way to go, since it will write a file out and serve that file until it is signaled it should be overwritten.

The main (only?) benefit is it’s more portable; you can work on it somewhere’s else but where you have FTP/WebDAV available (say the lobby of the Hilton in Austin during SXSW, or the Conference on Spasmic Flinching in Helsinki you’ve been really, really wanting to attend).

In addition, some folks are more comfortable using template code then making a .php file serve CSS correctly and use PHP embedded in the file. As of course, to some this is more important than the esoterica of php’s header() (no matter how easy it REALLY is).

Not to mention all that caching business. Bleh!

So in a way, couple the two and if you need dynamic features, you’re prolly better off with an EE template than a static .php file, as long as you performance tune and pay attention.

FWIW

 Signature 

 
“If you love the truth, you’ll trust it - That is,
you will expect it to be good, beautiful, perfect, orderly, etc…
In the long run, not necessarily in the short run.”
- Abraham Mazlow
 
“Truth is a long-term proposition.
Honesty, day to day, is malleable.
We learn honesty by studying truth,
In all it’s nature, in all it’s hope.”
- Unknown

When posting template code or HTML, use code wrappers to highlight code in posts. Thank you!

Profile
 
 
Posted: 06 September 2008 10:27 AM   [ Ignore ]   [ # 8 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1485
Joined  08-28-2003
pengwnfistoffury - 04 September 2008 11:20 AM

It totally fine either way. Some people like it being in the EE control panel so if they are out of town or away from there office, they can make changes to the css file via an internet browser. I personally keep my style sheets out of EE, but that is just me.

Yep, it doesn’t matter which you choose so long as it works for you.

For some sites I keep the CSS in templates because they’re easy to edit on the fly. For others, I use an editor and upload the CSS file to the server instead of using the templates.

One thing I’ve done with EE’s forums module is remove the CSS from the forums templates and place it as a file on the server. Looks to me like half the forums page is CSS, so page loading is quicker that way.

But as to EE sites I do both.

And I love CSSEdit.

 Signature 

RonnieMc

Honolulu, HI USA

HomeMac360

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65086 Total Logged-in Users: 38
Total Topics: 82224 Total Anonymous Users: 13
Total Replies: 441921 Total Guests: 201
Total Posts: 524145    
Members ( View Memberlist )