Seasons Display
So I wanted to have a little season icon and text that would change based on the calendar, so I managed to get this working.
Quote:
$today = new DateTime();
if(new DateTime() < new DateTime($today->format('Y').'-3-20 00:00:00')) $season = "Winter <img src='https://i.imgur.com/yYgkRTD.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-6-21 00:00:00')) $season = "Spring ";
else if (new DateTime() < new DateTime($today->format('Y').'-9-22 00:00:00')) $season = "Summer <img src='https://i.imgur.com/NwNeO64.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-12-20 00:00:00')) $season = "Fall <img src='https://i.imgur.com/vWiRVTe.png'>";
else $season = "Winter <img src='https://i.imgur.com/yYgkRTD.png'>";
$this->moneyBar->add(new Comment("<b id='season'>{$season}</b><br>"));
|
You can see where I have the little image icons beside my season's text.
I pasted this into the protected function setMoneyBar area of
class_sidebar.php file. So my code looks like this:
Quote:
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$today = new DateTime();
if(new DateTime() < new DateTime($today->format('Y').'-3-20 00:00:00')) $season = "Winter <img src='https://i.imgur.com/yYgkRTD.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-6-21 00:00:00')) $season = "Spring ";
else if (new DateTime() < new DateTime($today->format('Y').'-9-22 00:00:00')) $season = "Summer <img src='https://i.imgur.com/NwNeO64.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-12-20 00:00:00')) $season = "Fall <img src='https://i.imgur.com/vWiRVTe.png'>";
else $season = "Winter <img src='https://i.imgur.com/yYgkRTD.png'>";
$this->moneyBar->add(new Comment("<b id='season'>{$season}</b><br>"));
$this->moneyBar->add(new Comment("You have {$mysidia->user->money} {$mysidia->settings->cost}.<br>"));
$donate = new Link("donate");
$donate->setText("Transfer Freedom Points");
$this->setDivision($this->moneyBar);
}
|
___________________
Day/Night Cycle
I also wanted to create a code for changing my explore page image map based on day and night. So for this I made a page for my image map area called Map.
So first you need to create the regular php page in your root folder.
public_html. You can call it whatever, but I called mine map.php and inside paste this:
Quote:
<?php
class MapController extends AppController{
public function __construct(){
parent::__construct("member");
}
}
|
and save. Then in your view folder, create a new file called (whatever you pick)view.php. Mine was mapview.php.
Paste this into the view file:
Quote:
<?php
class MapView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("<br>The Wild<br><br>");
$h = date('G'); //set variable $h to the hour of the day
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
if ($h < 12) $img = "<img src='https://i.imgur.com/sa78yME.jpg' width='750' usemap='#image-map'>";
else $img = "<img src='https://i.imgur.com/rWiXA8c.jpg' width='750' usemap='#image-map'>";
//
$document->add(new Comment("{$img}<br>"));
}}
|
Hope this helps anyone! I'll be working at figuring out how to get the time and calendar to work together but right now you'll have to switch the day and night image out for each new season. Once I get it figured out I'll add it.