Archive for the ‘Smarty’ Category

Returning from a template

Monday, July 25th, 2011

Ever needed to return from a template earlier than at its end? Exit in the middle or even at the very beginning because you don’t want to print the rest of the template?

How to concatenate two object attributes and assign the result to a variable

Tuesday, March 4th, 2008

All right, this is really no rocket science it’s just something I needed and took me some time to figure out.

  1. "fullName""`$human->first` `$human->last`"}

or more robust version:

  1. "fullName"}
  2. {$human->first} {$human->last}

Date formatting in Smarty

Wednesday, September 26th, 2007

If you use the so called, German date format (day of month. month. year) you may have wondered how to achieve it with Smarty – without the leading zeroes for month.

How to report messages to user

Wednesday, September 26th, 2007

In the course of executing a program you need to report errors / success messages to the user. But you don’t want to mix your code with HTML, right? (A quick explanation on separating presentation from business / data logic.)

So here’s what I use: