- It can be used on any file through $mysidia->template->assign(), as long as you declare mysidia ($mysidia = Registry::get("mysidia")). I've been using most assigns in class_template though, in assignTemplateVars() function, or in class_frame, but that's personal choice I guess. I chose those two since they are always loaded for every page
- You can also do an assign for the image link and then in the template use it wherever you want, like:
//in class_template
PHP Code:
//you can use any other date function you wish xD
$now = new DateTime();
$hrs = $now->format('G');
$img = "";
if ($hrs > 0) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After midnight
if ($hrs > 6) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After 6am
if ($hrs > 12) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After noon
if ($hrs > 17) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After 5pm
if ($hrs > 22) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After 10pm
$this->assign("timeimg",$img);
//in template.tpl or header.tpl, wherever you want it
<img src={$timeimg}>
You can assign both the time and the image at once like this if you wish. Of course, it will only refresh with a page refresh xD
- PHP is pretty much normal with brackets, if the IF condition only has one line, you need no backets, like in Javascript ^^