Hallo,
ich brauche eine Funktion mit der man feststellen kann, ob für einen Block Daten vorhanden sind. Z.Z. behelfe ich mich mit folgender Funktion (in frontend.functions.
php):
if (!function_exists('has_page_content')) {
function has_page_content($block = 1) {
// Get outside objects
global $TEXT,$MENU,$HEADING,$MESSAGE;
global $globals;
global $database;
global $wb;
$admin = & $wb;
if ($wb->page_access_denied==true) {
return false;
}
if ($wb->page_no_active_sections==true) {
return false;
}
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
// Make sure block is numeric
if(!is_numeric($block)) { $block = 1; }
// Include page content
if(!defined('PAGE_CONTENT') OR $block!=1) {
$page_id=$wb->page_id;
// First get all sections for this page
$query_sections = $database->query("SELECT section_id,module,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
// If none were found, check if default content is supposed to be shown
if($query_sections->numRows() == 0) {
if ($wb->default_block_content=='none') {
return false;
}
if (is_numeric($wb->default_block_content)) {
$page_id=$wb->default_block_content;
} else {
$page_id=$wb->default_page_id;
}
$query_sections = $database->query("SELECT section_id,module,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
// Still no cotent found? Give it up, there's just nothing to show!
if($query_sections->numRows() == 0) {
return false;
} else {
return true;
}
} else {
return true;
}
} else {
return true;
}
}
}
Aufgerufen wird das folgender massen:
<?php if (has_page_content(4)) {
echo "<div class=\"leftcol\">\n\r";
page_content(4);
echo "</div>\n\r";
};
?>
Gibt's dazu was besseres?
und Tschoe
Willie