View Single Post
  #25  
Old 06-14-2014, 02:30 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 19,388
IntoRain is on a distinguished road
Default

- 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 ^^
__________________


asp.net stole my soul.
Reply With Quote