modified broadcast page

master
campi 2 years ago
parent 5f2b9137f0
commit 30ad48a2f3

@ -5,7 +5,42 @@
*/
?>
<?php
function create_onair_banner() {
$week = ["Luned&igrave","Marted&igrave","Mercoled&igrave","Gioved&igrave","Venerd&igrave","Sabato","Domenica"];
$content = $day = $cadence = $start_time = "";
$day = get_post_meta(get_the_ID(), 'on_air_day_0', true);
if (empty($day)) {
$content .= '<p style="color:#0bfafa">---> Trasmissione conclusa <---</p>';
} else {
$x = 0;
do {
$start_time = get_post_meta(get_the_ID(), 'on_air_start_'.$x, true);
$cadence = get_post_meta(get_the_ID(), 'on_air_cadence_'.$x, true);
$litteral_day = $week[((int)$day) - 1];
switch((int) $cadence) {
case 2: //ogni 2 settimane
case 3: //ogni 3 settimane
case 4: //ogni 4 settimane
$text = "$cadence $litteral_day";
break;
case 5: //una volta al mese
$start_date = get_post_meta(get_the_ID(), 'on_air_start_date_'.$x, true);
$day_of_the_month = which_day_of_the_month(new DateTime($start_date));
$text = "{$day_of_the_month}a $litteral_day del mese";
break;
default: //settimanale e altro non gestito (errori, etc.)
$text = "$litteral_day";
break;
}
$content .= '<p style="color:#0bfafa">---> In diretta ogni '.$text.' dalle ore '.$start_time.' <---</p>';
$x = $x + 1;
$day = get_post_meta(get_the_ID(), 'on_air_day_'.$x, true);
} while (!empty($day));
}
return $content;
}
get_header();?>
<main>
@ -26,18 +61,10 @@ get_header();?>
<figure style="margin-bottom:2em; width:45%; padding:1em; float:right">
<?php echo get_the_post_thumbnail(get_the_ID(), 'full'); ?>
</figure>
<?php
the_content();
$on_air = get_post_meta(get_the_ID(), 'on_air_day_0', false);
$start_time = get_post_meta(get_the_ID(), 'on_air_start_0', false);
?>
<?php the_content(); ?>
<div class="on-air">
<?php /*Se $onair[0] non è valorizzato la trasmissione non ha diretta e quindi è conclusa */ ?>
<?php if (empty($on_air[0])) { ?>
<p style="color:#0bfafa">---> Trasmissione conclusa <---</p>
<?php } else { ?>
<p style="color:#0bfafa">---> In diretta ogni <?php echo $week[$on_air[0]-1]; ?> dalle ore <?php echo $start_time[0]; ?> <---</p>
<?php } ?>
<?php echo create_onair_banner(); ?>
</div>
<br>
<!-- Link all'archivio delle puntate -->
@ -53,22 +80,12 @@ $category_link = get_category_link( $category_id );
<?php
$cat_id = get_post_meta(get_the_ID(), 'taxonomy_id', true);
//$cat_id = get_the_category(get_the_ID());
/* echo '<pre>';
print_r($cat_id);
echo '</pre>';
*/
$last_posts = get_posts(
array(
'numberposts' => 3,
'category' => $cat_id
)
);
//echo '<pre>';
//print_r($last_posts);
//echo '</pre>';
foreach ($last_posts as $s_post) {
$american_data = explode(" ", $s_post->post_date);
$data_a = explode("-", $american_data[0]); ?>

Loading…
Cancel
Save