Osiągnąć chciałbym by móc sterować tymi wartościami i móc wybrać jaka petla if ma się wyświetlać na stronie.
Tutaj mam co nie co naskrobane, tyle że wyświetla błąd.
Błąd:
Kod
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: songtitle
Severity: Notice
Message: Undefined variable: songtitle
Zawartość controlera
Kod
public function index() {
require APPPATH . 'vendor/Shoutcastv2.php';
$sc = new CI_Shoutcast(Settings_model::$db_config['shoutcast_host'], Settings_model::$db_config['shoutcast_port']);
//$content_data = array();
if (Settings_model::$db_config['shoutcast_version'] == 2) {
if (! $sc->getBasicStats()) {
$content_data['error'] = $sc->getError();
} else {
$content_data['currentlisteners'] = $sc->currentListeners;
$content_data['peaklisteners'] = $sc->peakListeners;
$content_data['maxlisteners'] = $sc->maxListeners;
$content_data['uniquelisteners'] = $sc->uniqueListeners;
$content_data['bitrate'] = $sc->bitrate;
$content_data['songtitle'] = $sc->songTitle;
}
}
$content_data['streamstatus'] = $sc->streamStatus;
$this->quick_page_setup(Settings_model::$db_config['active_theme'], 'main', 'Shoutcast', 'shoutcast', 'header', 'footer', Settings_model::$db_config['active_theme'], $content_data);
}
require APPPATH . 'vendor/Shoutcastv2.php';
$sc = new CI_Shoutcast(Settings_model::$db_config['shoutcast_host'], Settings_model::$db_config['shoutcast_port']);
//$content_data = array();
if (Settings_model::$db_config['shoutcast_version'] == 2) {
if (! $sc->getBasicStats()) {
$content_data['error'] = $sc->getError();
} else {
$content_data['currentlisteners'] = $sc->currentListeners;
$content_data['peaklisteners'] = $sc->peakListeners;
$content_data['maxlisteners'] = $sc->maxListeners;
$content_data['uniquelisteners'] = $sc->uniqueListeners;
$content_data['bitrate'] = $sc->bitrate;
$content_data['songtitle'] = $sc->songTitle;
}
}
$content_data['streamstatus'] = $sc->streamStatus;
$this->quick_page_setup(Settings_model::$db_config['active_theme'], 'main', 'Shoutcast', 'shoutcast', 'header', 'footer', Settings_model::$db_config['active_theme'], $content_data);
}
View
Kod
<?php if (!empty($streamstatus)) { ?>
<?php print $songtitle; ?>
<?php print $peaklisteners; ?>
<?php }else{ ?>
<?php print $error; ?>
<?php } ?>
<?php print $songtitle; ?>
<?php print $peaklisteners; ?>
<?php }else{ ?>
<?php print $error; ?>
<?php } ?>
Dokładnie chodzi mi o tp:
Kod
if (Settings_model::$db_config['shoutcast_version'] == 2) {
Gdzie wartość 2, wyświetla wybraną funkcje którą chce uzyskać