Hello!
I wrote a small snippet for a private radio site. It checks wheather a stream is running or not and then puts the information in two placeholders.
Here is the code:
<?php
$dbase = $modx->dbConfig['dbase'];
$table_prefix = $modx->dbConfig['table_prefix'];
$sql = "SELECT DJserverIP, DJserverPORT, DJonline FROM modx_web_user_attributes_extended WHERE DJonline LIKE 'on' ";
$result = $modx->dbQuery($sql);
$number = $modx->db->getRecordCount($result);
if($number==0 || $number>1) {
$outputLink .= '<h1><a id="big-button" href="index.php?id=54" title="Kein Stream am laufen!">Kein Stream am laufen!</a></h1>';
$outputStats = '<strong>Kein Stream am laufen! Schau am besten mal ins <a href="index.php?id=53" title="Programm">Programm</a>.</strong>';
}
else {
$row = $modx->db->getRow($result);
$DJserverIP = $row['DJserverIP'];
$DJserverPORT = $row['DJserverPORT'];
$DJonline = $row['DJonline'];
$outputLink .= '<h1><a id="big-button" href="http://' . $DJserverIP . ':' . $DJserverPORT . '/listen.pls" title="Listen to our Radio Stream!">TUNE IN</a></h1>';
$outputStats .= 'http://' . $DJserverIP . ':' . $DJserverPORT . '/';
}
//echo $outputStats;
$modx->setPlaceholder('DJonlineStats',$outputStats);
$modx->setPlaceholder('DJonlineLink',$outputLink);
return;
?>
I know it is not the nicest code but it worked fine, until i added the second placeholder (DJonlineStats, with $outputStats). It seems like the placeholder is recognized, but is not displaying its content. The rest is still working fine.
The strange thing is after adding the "echo $outputStats;" at the end of the script, the information was succesfully shown as the echo and the placeholder.
I have no idea why it works with the echo command and not without it..
Any suggestions?
regards,
AvrantiS