in Thesis Thursday · May 28, 2009

Tips For Keeping Your CSS & Functions Organized

One of thing that sets The­sis apart from other themes is the way you can edit it. You are only required to edit two files to make any cus­tomiza­tions through­out your whole website.

Those two files, as you may know, are custom_functions.php and custom.css. The rea­son­ing behind this is 100% for orga­ni­za­tion pur­poses. In reg­u­lar Word­Press themes, you have many files to work from. In The­sis, you just have two. It makes so much more sense, and it will ulti­mately make your site run faster.

The only prob­lem I have with edit­ing only two files is that every­thing can start to get rather clut­tered. You con­trol every ele­ment and every piece of the lay­out in these two files, that if you have a lot of cus­tomiza­tions — you’re going to have a mess.

The rea­son this even occurred to me is because my other blog, Blo­gus­sion is a very heav­ily edited ver­sion of The­sis that has a lot of cus­tom CSS, and a lot of dif­fer­ent func­tions. I looked into the files one day and real­ized that I made a mess!

As I was edit­ing, this idea for a The­sis Thurs­day post came into my head. I’m going to share with you the things I did to keep my files more orga­nized. You can apply some of these tips to any theme really, but I’m going to be speak­ing in The­sis through­out this tuto­r­ial (yes, I did just refer to The­sis as a language).

.cus­tom” is ONLY needed on styles you are edit­ing from the default style!

This was a mis­take I made at first, and is some­thing I think is being made on some other The­sis pow­ered blogs as well.

If you read the instruc­tions in the default custom.css file, you will see that:

You can use the “cus­tom” class to over­ride *any* CSS dec­la­ra­tions con­tained in the style.css file.

If you skim through things like me, that file prob­a­bly read to you as “Use .cus­tom to add CSS here.” Just know that you only need to add “.cus­tom” in front of the class you are edit­ing from the default style.css. If you made some­thing up on your themes, you do not need “.cus­tom” in front of it!

Cre­ate A Color Code Chart

I actu­ally picked this trick up from Chris Coyier, and I think that any designer, not just a The­sis designer should lis­ten to.

Design­ing has a lot to do with con­sis­tency. In your theme, you don’t want to use a lot of dif­fer­ent col­ors because it can look really weird and tripped out. I find that if you cre­ate a color chart of all of the col­ors you use through­out your cod­ing, you will be in some good shape.

This is what I did at Blo­gus­sion, I com­mented these color codes at the top of the file and when­ever I needed a spe­cific color, I just scrolled to the top and got it.

COLOR CHART
RED:#B82626
BLACK:#312F2F
LIGHT GRAY:#CCC
DARK GRAY:#B82626
WHITE:#F1F1F1

You don’t even have to keep it in your CSS, maybe a file you keep some­where on your desk­top or something.

Use Com­ments!

Using com­ments in your CSS will help a lot, espe­cially in The­sis. Because you usu­ally don’t write many of your own styles, but edit them, hav­ing some com­ments around are cru­cial for editing.

You don’t know what most of the names are, and what exactly they con­trol from the name all the time. So by dis­tin­guish­ing where each line of code goes, it will help you a lot.

Limit Com­ments, Cre­ate Func­tions Table

This is some­thing I’ve done exper­i­men­tally. The func­tions file is PHP based, and I am not really knowl­edge­able with the lan­guage. I don’t know how files are orga­nized usu­ally, but this is what I can say I do in my custom_functions file.

A. Cre­ate A List of All Func­tion Names

When I name my func­tions, I copy and paste the name to the top of the file. This is kind of like the style sheet color chart I talked about above. I com­ment in at the top “Func­tions Chart” and put all of the func­tion names below it. Since I have a lot of func­tions, this is ideal for me to do.

B. Remove Any Other Comments

Once I have all of the func­tion names at the top, I don’t need com­ments to make read­ing the func­tion name eas­ier. I would nor­mally just add a com­ment above each func­tion with the name because look­ing at all of the dif­fer­ent PHP code would get me confused.

C. Now Locat­ing Func­tions Is Easier

If you need to find a func­tion now, you can just open up custom_functions.php, look through your name chart, go to your Search Box (usu­ally CTRL/CMD + F) and paste the func­tion name right in. It will find it, and jump you right down to the func­tion you want to edit.

I hope I explained that well enough for you to under­stand! You can also apply the same thing with your CSS, I think it’s way eas­ier than remem­ber­ing the names of the func­tions and classes if you have a nice lit­tle table at the top of the page to remem­ber it all for you.

More The­sis Orga­ni­za­tion Tips

I hope you have learned a thing or two about keep­ing your The­sis files nice and clean. A lot of these tips will be use­ful for you if you do a lot of cus­tomiza­tions, but if you don’t have that many, it may not be as handy.

{ 1 trackback }

links for 2009-06-02 — girliegeek
June 2, 2009 at 3:03 AM

{ 13 comments… read them below or add one }

1 Jorge - Nokia Mobile Talk May 28, 2009 at 8:08 PM

Nice tips !!

Reply

2 Harsh Agrawal May 28, 2009 at 8:43 PM

Thanks I always mess up by adding more codes to my files, and in the end when I go back to edit them I always mess up with my theme.

Reply

3 Alex May 28, 2009 at 9:11 PM

I know, me too!

I don’t know what’s worse, cod­ing a bunch of unnec­es­sary CSS with­out think­ing about it, or going back and remov­ing it all.

Reply

4 Kathy Purdy May 29, 2009 at 2:39 PM

I have kept the same color palette through sev­eral redesigns of my web­site. I store it in a spread­sheet for easy ref­er­ence. For each color, I have the hex code, the RGB code, and an actual color sam­ple. I also list what I tend to use the color for–background, text, links, etc. It was a bit tedious to set up, pick­ing cus­tom col­ors from a color picker for each color, but has save me loads of time since then.

Reply

5 George Serradinho June 1, 2009 at 10:15 AM

Hi,

I have tried to keep my cus­tom func­tion file as clean as pos­si­ble, but have descrip­tive com­ments to help me under­stand later. I have put all my hooks on top so that I can ref­er­ence them quicker.

Reply

6 Ryan June 3, 2009 at 5:05 PM

In order to keep your custom_functions.php file bet­ter orga­nized, you might find my The­sis Exten­sions tech­nique use­ful. Each hook/handler func­tion combo can go into a unique descrip­tively named file.

Reply

7 S.Pradeep Kumar June 20, 2009 at 12:34 PM

Nice ! :)

CSS is one of the main rea­son for my love in The­sis ! ;)
S.Pradeep Kumar´s last blog ..How And Why To Con­vert Your Blog Into A Do Fol­low Blog? My ComLuv Profile

Reply

8 Justin June 22, 2009 at 8:07 PM

Thanks for the tips, I’m new to The­sis, CSS, and blog­ging in general!

One that really stood out to me was adding a color chart to your CSS files.

Reply

9 Alex June 24, 2009 at 11:32 AM

Yeah, that’s really use­ful if you use it right. Thanks for stop­ping by!

Reply

10 S.Pradeep Kumar July 3, 2009 at 10:58 AM

Buddy when I clicked these links “Valid xHTML | Valid(ish) CSS” it showed the val­i­da­tion page of this post .. but in some other blogs .. they showed val­i­da­tion page of blog’s home­page instead..

Note : I com­mented this hop­ing this is done by mis­take.. but you might also did like what it is now.. ! ;) Cheers !
S.Pradeep Kumar´s last blog ..Miles To Walk Before 2009 (Site Goals) My ComLuv Profile

Reply

11 S.Pradeep Kumar July 3, 2009 at 11:02 AM

Check the links in the Footer sec­tion named “Under The Hood” and not the links in the above com­ment ! :)
S.Pradeep Kumar´s last blog ..Miles To Walk Before 2009 (Site Goals) My ComLuv Profile

Reply

12 adnan January 28, 2010 at 10:51 AM

hello every­one.., great place this asnio!
I have a ques­tion maybe not to related to the post but more to the­sis design­ing.
The sce­nario looks like this:

I’ve added a func­tion the other day which uses the “thesis_hook_after_headline” hook.
I wan­nit to add this post rat­ing plu­gin for word­press and so I build the func­tion:

function post_rating()
{
if (is_single()) { ?>

<?php }
}
add_action(‘thesis_hook_after_headline’, ‘post_rating’);

every­thing was great until I tried to give it some style through the custom_css file.

So, the ques­tion is how do I access this func­tion or this hook through css?

What i tried is some­thing like:


.post_rating {
text-align: right;
padding-top:5px;
padding-bottom:5px;
}

or


.custom .post_rating {
text-align: right;
padding-top:5px;
padding-bottom:5px;
}

and there were a few other ways I tried it but non of was effective

so the part which I don’t know is:


.custom .post_rating { - is this place here
text-align: right;
padding-top:5px;
padding-bottom:5px;
}

I would really appre­ci­ate it if some­one had some solu­tions or the answer.
thanks in advance.

Reply

13 katinka February 18, 2010 at 6:03 AM

Great tips. I already did the color-chart at the top thing, but doing some­thing sim­i­lar with func­tions is going to really help me keep track.
katinka´s last blog ..Free will, free­dom and phi­los­o­phy series My ComLuv Profile

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled