WordPress and Templates

WordPress seems to be an interesting blog, its nice to see opensource working. Development on B2 might have slowed and then died, but there is still life for the codebase through the work on wordpress. I just messed around a bit with the template and some css, im not really sure if i like the color scheme but i like that fact that wordpress just uses normal php and not some special template. Reminds me of my journey away from Smarty and to Savant. Those of you not involved deeply in PHP might not know have had the joy of the templating argument but it generally goes like this.

  1. We must seperate display from logic
  2. Looks like the way to do this is using templates
  3. Lets make something really complicated and make our own templating language

Now many people might not agreee with me that the language that Smarty or any other templating language is complicated but even if your argument thats its simple is correct think of a couple points. Most people who are going to use it either know PHP and HTML, HTML and javascript, or just HTML. So your common denomiators are C syntax scripting languages and HTML. So your target really should be something that looks a lot like PHP, or something that looks like a lot like HTML.

I’m pretty sure that the Smarty code example below looks nothing like either:

{if $highlight_name}
Welcome, {$name}!
Welcome, {$name}!
{include file="footer.tpl"}

Its not that i think this is all that complicated but its something new to learn, and isn’t like the other technologies web people need to work with.So that brings me to just using php for the template engine.

  • Its simple and fast
  • echo $myvariable; makes sense for anyone that already knows PHP or javascript
  • Your template engine isn’t a 120Kb tarball

For more details on the subject read ts on the subject over at phpPatterns.

Posted in PHP

2 thoughts on “WordPress and Templates”

  1. i wanted to know from where it will get the value of “$highlight_name”? in “{if $highlight_name}” statement? will it get it from .php file or some where ele?


  2. Mannan
    in both smarty and savant variables are assigned to the template and then the template is displayed. So $highlight_name is a boolean passed in from the php page that built this page.

Comments are closed.