I decided to give the Smarty Template Engine a go tonight. I downloaded it pretty easily and moved it to my htdocs folder to try out. My initial impression of the code was that it was pretty powerful and I was going to enjoy working with it. When I loaded it up on the browser though I was faced with some error messages. Not one likes to see errors when they haven’t even started writing their own code!
So I started down the “winging it” road and decided I would learn from doing and reading the demo code (even though it wasn’t working yet).
The first step is to create a test directory. My path was to C:\xampp\htdocs\smarty\test\ (I left the /lib/ directory that contains the core Smarty code in the parent directory, /smarty/. Now the thing to note is that for all intensive purposes, your web site or application is going to live inside this /test/. So when a tutorial says to create a /templates/ folder, it should be at C:\xampp\htdocs\smarty\test\templates\. It will become a bit more evident as you start using Smarty more and more, but essentially that is the standard. When you go to include a template file you are able to call just the file name. If you had put the template directory in a parent or sibling folder, you would need to use relative or absolute paths to prepend the file name.
- htdocs - smarty - lib - test - templates