HostOrca Posted April 11, 2010 Share Posted April 11, 2010 Hi I have searched the docs and forum for an answer to this but can not find an answer. I am trying to edit the serverstatus page to add a link using the hostname for the server (as set in the server setup page (admin). But I can not seem to work out the variable to use. Any help would be apreciated. 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted April 12, 2010 Share Posted April 12, 2010 Be default there isn't a variable available for this. A solution is the code below. Just add it at the top of your serverstatus.tpl. {php} foreach ($this->_tpl_vars['servers'] as $key => $value) { $result = select_query("tblservers","hostname",array("name" => $value['name'])); $data = mysql_fetch_array($result); $this->_tpl_vars['servers'][$key]['hostname'] = $data['hostname']; } {/php} You can request it inside the foreach with {$server.hostname}. 0 Quote Link to comment Share on other sites More sharing options...
HostOrca Posted April 12, 2010 Author Share Posted April 12, 2010 Thanks m00 I'll give that a go tonight. 0 Quote Link to comment Share on other sites More sharing options...
HostOrca Posted April 12, 2010 Author Share Posted April 12, 2010 Be default there isn't a variable available for this. A solution is the code below. Just add it at the top of your serverstatus.tpl. {php} foreach ($this->_tpl_vars['servers'] as $key => $value) { $result = select_query("tblservers","hostname",array("name" => $value['name'])); $data = mysql_fetch_array($result); $this->_tpl_vars['servers'][$key]['hostname'] = $data['hostname']; } {/php} You can request it inside the foreach with {$server.hostname}. Just tried and it works with just one problem. This is the code in full: {php} foreach ($this->_tpl_vars['servers'] as $key => $value) { $result = select_query("tblservers","hostname",array("name" => $value['name'])); $data = mysql_fetch_array($result); $this->_tpl_vars['servers'][$key]['hostname'] = $data['hostname']; } {/php} <p>{$LANG.serverstatusheadingtext}</p> <table width="100%" border="0" align="center" cellpadding="10" cellspacing="0" class="data"> <tr align="center"> <th>{$LANG.servername}</th> <th>cPanel</th> <th>HTTP</th> <th>MySQL</th> <th>FTP</th> <th>POP3</th> <th>{$LANG.speedtest}</th> <th>{$LANG.serverstatusserverload}</th> <th>{$LANG.serverstatusuptime}</th> </tr> {foreach key=num item=server from=$servers} <tr align="center"> <td>{$server.name}</td> <td>{get_port_status num="$num" port="2082"}</td> <td>{get_port_status num="$num" port="80"}</td> <td>{get_port_status num="$num" port="3306"}</td> <td>{get_port_status num="$num" port="21"}</td> <td>{get_port_status num="$num" port="110"}</td> <td><a href="{$server.hostname}/speedtest.html" target="_blank">{$LANG.speedtest}</a></td> <td>{$server.serverload}</td> <td>{$server.uptime}</td> </tr> {foreachelse} <tr> <td colspan="7">{$LANG.serverstatusnoservers}</td> </tr> {/foreach} </table> The problem is the link generated by this ><a href="{$server.hostname}/speedtest.html" target="_blank">{$LANG.speedtest}</a> makes the link http://whmcsdomain.co.uk/hostname/speedtest.html Any ideas 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted April 12, 2010 Share Posted April 12, 2010 Put http before the link: <td><a href="http://{$server.hostname}/speedtest.html" target="_blank">{$LANG.speedtest}</a></td> 0 Quote Link to comment Share on other sites More sharing options...
HostOrca Posted April 12, 2010 Author Share Posted April 12, 2010 Thanks a lot m00! That did it!! (I now go off to kick myself for missing something so obvious!!!!) 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.