Technical Philosophy - Templates/Generic Tags
Posted in general - July 4, 2008

First some of My Definitions:

(Graphic) Designer - Photoshop/Illustrator image creator

(Web) Designer - HTML/CSS writer

(Web) Developer - PHP programmer

I love listening to developers talk about the philosophical issues of web development. Such as separation of style, structure, code, design, business-logic, presentation and WHATEVER ELSE. I believe everybody thinks its ideal and nice... but the difference comes in actually implementing it. It can become a task of its own. Some people don't think its worth the trouble. I think the worst solution is solutions like smarty where they basically create a new language for templating... when PHP is a templating language in its self. I do see some benifits of smarty but I just think it makes sense.

This is my break down of what I think is makes sense.

Website Templates:

Most of the time developers give designers less credit than they deserve.

I believe a designer can modify a template with some PHP foreach loops and insert variables accordingly with out destroying an application. They don't have to create the foreach loops... that's why its called a TEMPLATE the developer should create all of the logic before hand.

The Logical Site Template

(for developers and designers!)

Functionality

This template will simply be a PHP file. Maybe a file maybe named my_template.tpl.php or something.

It should only contain variables <?=$my_variable?> or <?php echo $my_variable; ?>

and simple base logic and variables. <?php foreach($menu as $page_name => $page_url){ ?> <!-- Insert html here --> <?php } ?> or something along those lines... whatever you prefer. Just make sure you limit your self to very basic page display logic.

Absolutely no functions or crazy stuff in here.

Reasoning

  • Why?
    • Your designer and developer are comfortable with the designer editing inside of a php file (In my opinion no big deal, no excuse to not know the very basics of PHP if your a web designer)
    • More flexibility
    • LESS TEMPLATE FILES (You don't have to create a template for every foreach block
  • Why Not?
    • Not TRUE separation of logic and design.
    • May start to get ugly if theres too much logic going on
    • No real physical constraints on what can be used and what cannot

The Simple Site Template

(for developers and designers!)

Functionality

This will container absolutely no logic. It will only be able to use php variables. Works exactly like a like a php HEREDOC. Example would be. <b>$my_variable</b> or accessing array values with {$my_array['foo']}

I think <!--$my_variable--> or /*$my_variable*/ should be available as well to work just the same for validation and editor purposes. Obviously the extra tag content will be stripped away by the variable value.

This type of template is REALLY php... just can only access variables.

  • Why?
    • You think your designer has absolutely not concept of PHP
    • You want to keep absolute separation of logic and presentation
  • Why Not?
    • You can not use loops in the file, loops will be done through a separate template file. (this can become daunting)

Choosing Between the two

Choosing which template to use should be up to the developers philosophy, time, and designers knowledge, and both of your patience.

If your a really hard core logic/design segregationist. Then use the "simple site template" it is also very simple for the designer.

Use simple site template If you realize that your designer isn't retarded, and can work with a simple php file. As well as If you have discipline to work with the php file without introducing tones of logic and can keep functions out.

Content Templates

(for end users)

Functionality

This should be used for end user variables. THIS IS NOT BB CODE. The end user should be able to use whitelisted HTML which is pre validated (best solution by far). I choose to use brackets because it doesn't require the shift key which means its quickly accessible and simple. Its also aesthetically pleasing and a clear separator.

P.S.

Working on a very small templating/tag system that goes with this philosophy. Hopefully I can finish it up and post the code this weekend!

Posted By YouDon'tMeanMuch at 6:50 pm

August 20, 2008 at 2:21 am  

neurocirculatory prayer underlining pinchedness sphagnum handistroke anomuran nourishment Birdie Fell - Chapel Stile http://www.lambrechtmotorhomes.be Dan Severn Training Center http://cnn.com/2003/WORLD/meast/07/20/sprj.irq.weapons.defense/ Sugjin International http://www.tsprinting.com/ Lynden Chamber of Commerce http://freespace.virgin.net/m.nash/vsalt.htm


Comment on this post

  Name:
  E-Mail:
  Website:
  Comment: