Hadeszeus 15 Posted February 6, 2014 (edited) Guys, I'm currently working on my CP using FLUX. I'm having problem changing the output text OFFLINE/ONLINE in MAP SERVER STATUS. Here's the original code: <table><?php foreach ($serverStatus as $privServerName => $gameServers): ?> <?php foreach ($gameServers as $serverName => $gameServer): ?> <tr> <th class="server"><?php echo htmlspecialchars($serverName) ?></th> <td class="status-login"><?php echo $this->serverUpDown($gameServer['loginServerUp'])?></td> <td class="status-char"><?php echo $this->serverUpDown($gameServer['charServerUp']) ?></td> <td class="status-map"><?php echo $this->serverUpDown($gameServer['mapServerUp']) ?></td> <td class="status-online"><?php echo $gameServer['playersOnline'] ?></td> </tr> <?php endforeach ?></table> Here's my if statement to change the text to image (I used text to echo the return value for testing purposes only.) The problem is even if the server is Offline the status still display green text instead of red <td class="status-login"><?php if($this->serverUpDown($gameServer['loginServerUp']) == "Offline") {echo "red";} else {echo "green";}?></td> Any thoughts? Thanks! Edited February 6, 2014 by Hadeszeus Quote Share this post Link to post Share on other sites
0 kazma 0 Posted February 6, 2014 to change text to image, I think it would change the "red" to "<img src="off image url" title="off"/>" and "green" to "<img src="on image url" title="on"/>" Quote Share this post Link to post Share on other sites
0 Hadeszeus 15 Posted February 6, 2014 to change text to image, I think it would change the "red" to "<img src="off image url" title="off"/>" and "green" to "<img src="on image url" title="on"/>" I said I only used text for testing purposes Quote Share this post Link to post Share on other sites
0 Hadeszeus 15 Posted February 6, 2014 Solved Quote Share this post Link to post Share on other sites
0 Mhalicot 392 Posted February 7, 2014 Please share how you solved your problem to mark it Solved thanks Quote Share this post Link to post Share on other sites
0 Hadeszeus 15 Posted February 8, 2014 (edited) The reason why the IF statement didn't work, because serverUpDown fuction is using bool to pass the output OFFLINE/ONLINE. Here's the orginal code: /lib/Flux/Template.php /** * Returns "up" or "down" in a span HTML element with either the class * .up or .down, based on the value of $bool. True returns up, false * returns down. * * @param bool $bool True/false value * @return string Up/down */ public function serverUpDown($bool) { $class = $bool ? 'up' : 'down'; return sprintf('<span class="%s">%s</span>', $class, $bool ? 'Online' : 'Offline'); } So to make it work. Just create a new function for serverUpDown. Something like this // filename of an image that represent that the Server is Online define('ONLINE_IMAGE', 'Online.png'); // filename of an image that represent that the Server is Offline define('OFFLINE_IMAGE', 'Offline.png'); function serverUpDownImage($bool) { $imgDown = THEME_PATH.'images/'.OFFLINE_IMAGE; $imgUp = THEME_PATH.'images/'.ONLINE_IMAGE; $class = $bool?'up':'down'; return sprintf('<span class="%s">%s</span>', $class, $bool?'<img src="'.$imgUp. '"/>':'<img src="'.$imgDown.'"/>'); } Edited February 8, 2014 by Hadeszeus Quote Share this post Link to post Share on other sites
Guys, I'm currently working on my CP using FLUX. I'm having problem changing the output text OFFLINE/ONLINE in MAP SERVER STATUS.
Here's the original code:
Here's my if statement to change the text to image (I used text to echo the return value for testing purposes only.)
The problem is even if the server is Offline the status still display green text instead of red
Any thoughts? Thanks!
Edited by HadeszeusShare this post
Link to post
Share on other sites