Professional Developer based in Egypt.
Doing the simple way.

easy_engine, php template engine,
Episode 1

Thursday 9th April, 2009 in php: easy_engine
Hi php lovers.

I will introduce you my new template engine developed after a long suffering with smarty engine and many small classes used for this purpose.

The idea to use template engine came to seperate view (user interface, your html, css, js files ... etc) from your server coding (php, database, logic layer ... etc). in the same time make integration easy to :
  • Modify the view within one place only, without any effect on your server coding.
  • Modify the coding without need to update many files in the views.

That seperation makes your web site or application very organized, easy to read, easy to maintain, easy to update.

To make it so easy we will build a tiny web site step by step.
Our web site is a corporate web site, having thes pages:
  • Home page
  • About page
  • Products page
  • Contact page

just that simple, we will create this web site in two files only:
  • template.html : which is the html template page, contain the design of the header and footer of the web site and all contents of all the 5 pages in it.
  • index.php which is our default page, views only the home page, when accessed this way index.php?about then it will return only the header, footer and the about page content, if you used index.php?products then it returns products part ... etc

Step 1

our template.html will look like this:
...... Home page contents here .... About page contents here .... Products page contents here .... contac page contents here ....

Step 2

Now we need to spare every section alone, so the engine later can read each section as a whole unit. we will call each section a name, like header, footer, home, about, products and contact. then we will use this syntax to define section: ...... section html content here ...... now we will reformat out template file to be converted into sections: ...... Home page contents here About page contents here Products page contents here contac page contents here
Now the engine should understand easily each section.

TO BE CONTINUED .. Follow up
1