Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
[TIP] Indent Table Elements
mashby
Join Date: Jan 2002
Posts: 736

Married, no kids yet, born in Louisiana and I'm hooked on the television show "24."

Nashville, TN - USA
by mashby mashby is offline 10 Sep 2002

Table problems are one of the most common problems that people run into when editing their templates. Forget to close a tag and your entire site can become crippled. To help fix this problem before it starts, I recommend that you indent each element when using tables. By simply adding a tab, or a few spaces to your code, you can make it easier to see if there's a problem with your code.

Compare the following two code samples and you'll see what I mean:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Which is easier to read? When I try and help someone with their code, one of the first things I do is reformat their code with indents. If there's a problem with a missing tag, you can be sure that I can find it in a jiffy with this method.

You'd be surprised at what a difference something as simple as this can make.
Views: 3974
Reply With Quote
Comments
  #2  
Old 12 Sep 2002, 09:18
Bad Bunny's Avatar
Bad Bunny Bad Bunny is offline
 
Join Date: Apr 2002
Another good point. I work with an editor that formats code (if I want it to) very similarly.
__________________
My cat's breathe smells like cat food!
Reply With Quote
  #3  
Old 12 Sep 2002, 10:06
Tony G's Avatar
Tony G Tony G is offline
 
Join Date: Nov 2001
Real name: ITS A SECRET
Yes thats how it's set in most template mods and the default templates. Much easier.
Reply With Quote
  #4  
Old 24 Sep 2002, 18:46
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
Indenting by using a TAB space is usually a bad idea, because the TAB character is interpreted differently on different platforms (which means you can have nice neat code on Windows, but try to edit it in Unix and you'll wonder what the hell happened).

vB uses TAB spaces everywhere, but as a general rule I stick to the '2 space' convention. That is, 2 non-breaking spaces for each indented line of code.

I've also set up my text editor to do the same. It makes for very nice, clean code.
Reply With Quote
  #5  
Old 25 Sep 2002, 02:07
Tony G's Avatar
Tony G Tony G is offline
 
Join Date: Nov 2001
Real name: ITS A SECRET
I just space as much as the other ones are, so I don't use TAB or anything.
Reply With Quote
  #6  
Old 28 Sep 2002, 18:09
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
The 'other spaces' are tab spaces.
Reply With Quote
  #7  
Old 28 Sep 2002, 18:10
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
Note: A TAB space is an actual character, so when I use that word I am referring to the character itself, not what happens when you press the TAB key (although in almost all cases they are the same).
Reply With Quote
  #8  
Old 29 Sep 2002, 02:33
Tony G's Avatar
Tony G Tony G is offline
 
Join Date: Nov 2001
Real name: ITS A SECRET
Originally posted by plattopus
The 'other spaces' are tab spaces.
Ahh, I had no idea they were. Well it's good to use them then for some clean code.

BTW can't try it in here because of the other input spaces.
Reply With Quote
  #9  
Old 29 Sep 2002, 16:08
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
It's not good to use them, because as I explained before you can't rely on their readability across all platforms. You can even change the size of TAB spaces to your liking in various programs, so you can pretty much be sure that your code will look different for everyone if you use TAB spaces instead of non-breaking spaces.
Reply With Quote
  #10  
Old 01 Oct 2002, 00:46
Brad Brad is offline
 
Join Date: Nov 2001
I never indent table elements, because ive known about the issues as i use both windows and linux, and i can read my code very well without them anyway.
Reply With Quote
  #11  
Old 01 Oct 2002, 11:30
Tony G's Avatar
Tony G Tony G is offline
 
Join Date: Nov 2001
Real name: ITS A SECRET
I can live with both, but I find it a little easier. It don't really matter anyway much to me.
Reply With Quote
  #12  
Old 01 Oct 2002, 13:53
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
Yeah it's usually easier... especially when you're dealing with a lot of nested tables. If you see a big jump in indents, that suggests you've either missed a few closing tags, or forgotten them.

Example:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It could be hard to notice errors in code like this (but far more complex, I only used this as an example)... this is much easier:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

You can see the big jump in space between the text and it's ending TD tag.
Reply With Quote
  #13  
Old 01 Oct 2002, 14:11
Tony G's Avatar
Tony G Tony G is offline
 
Join Date: Nov 2001
Real name: ITS A SECRET
I agree, I prefer the second way but I don't mind. I mean I can still spot errors without the indents but it could be harder.
Reply With Quote
  #14  
Old 18 Oct 2002, 15:25
Christoff's Avatar
Christoff Christoff is offline
 
Join Date: May 2002
Plattopus: upload your files in ASCII mode and there will be no problem with character coding
I often edit files on windows and after upload there is no diffrence from the one made on BSD
__________________
Christoff

E-Mail: christoff@plusnet.pl
ICQ UIN: 5107076

Forgive me my language :P
Reply With Quote
  #15  
Old 19 Oct 2002, 08:37
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
There is a difference, it might just be luck that both of the programs you used are configured similarly.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 09:59.

Layout Options | Width: Wide Color: