Jump to content
  • 0
Sign in to follow this  
Hadeszeus

Map Status Text change to Image

Question

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 by Hadeszeus

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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"/>"

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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 by Hadeszeus

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.