Tuesday, July 5, 2011

Templates

Templates are time consuming to create, but will save time in the long run if put together properly.

When doing your templates consider what you usually put into a web site that your doing.

Are you making allot of contact forms, edit screens, screens with different layouts? Are you using the same functions over and over again on different projects? Are you using the same field names over and over again, like street, city, name ecetera?

Create a folder called templates, and slowly add to it over time. It takes time and effort to create everything, but in the end it will save allot of time and frustration.

I would recommend that you start of with a couple of page templates for the visitor, then add a contact form, an edit screen, a login page with everything necessary to login to a content management area.

Slowly build up a list of html pages, javascript class objects, php classes, style sheets, and navagation buttons. While putting together your generic templates, think about how your going to use them. Everything should be reusable in one way or the other.

Dividers should be used whenever possible. They keep everything in proper alignment, load faster, and are compatible with most browsers.

When constructing your generic style sheet plan short and long dividers, and incorporate dividers with columns.

Columns are tricky. The basic setup for a column is an outside and inside divider. There can never just be one column unless the outside divider is equal to the inside divider; otherwise, you must add empty columns to fill out the rest of the space in the outside divider. (it may be possible to use padding).

Class objects should be used to put together like functions. They can be accessed via a single function with a parameter. For example;

bind (parm){

pnt = new operations();

if (parm="moverecords"){
pnt.moverecords();
}

}

It is a good idea to keep your form fields the same. A good way to do this is to setup a class with variables pointing to page objects, like;

address = document.getElement[txt_address].value;

Be careful. Always check to see if the object exists on the page before using it.

If your using Ajax, separate your Ajax functions into a separate file. Keep them as functions. Don't try to get fancy. There aren't too many of them, and it isn't worth the time or effort. The only thing you may want to do is to consolidate your if statements into a case structure.

Setting up all these templates can be time consuming in the beginning, but will save you time and money in the end.

Programming for the Web