SimplePortal
Customization => Custom Coding => Topic started by: ataru on April 16, 2015, 06:17:30 AM
-
I'd like to enable a block during determined periods.
e.g. Sunday, 26th March, from 3 PM to 5 PM
Is there any simple way to do that automatically?
-
ataru,
If it is a custom PHP block which has the title hidden then you can do that within the PHP code of the block.
Otherwise it will involve manual edits or perhaps a plug-in.
Is this a custom PHP block?
Regards.
-
it's a shoutbox block.
there's no way to nest a shoutbox block into a php block, right?
ok. found it:
http://simpleportal.net/index.php?topic=5332.0
-
How I did it:
$dataeorainizio = '2015-04-20 14:35:00'; //time to start displaying block
$minutididurata = '120'; //time (in minutes) to show block
$titoloblocco = 'A Title for this Block';
$iddelblocco = "50"
$dataoraadesso= new DateTime();
$dataoraavvioblocco = new DateTime($dataeorainizio);
$dataorachiusurablocco = new DateTime($dataeorainizio);
$dataorachiusurablocco->add(new DateInterval('PT'. $minutididurata . 'M'));
//echo $dataoraadesso->format('Y-m-d H:i:s');
//echo "<br>".$dataoraavvioblocco->format('Y-m-d H:i:s');
//echo "<br>".$dataorachiusurablocco->format('Y-m-d H:i:s').'<br>';
if ($dataoraadesso > $dataoraavvioblocco) {
if ($dataorachiusurablocco > $dataoraadesso) {
//echo 'show that block';
$block = current(getBlockInfo(false, $iddelblocco, false, false)); // Load block info
$block['label'] = $titoloblocco;
$block['style'] = sportal_parse_style('explode', $block['style'], true); //Parse block style parameters.
template_block($block); // Output the block.
} else {
//echo 'too late';
}
} else {
//echo 'early';
}
;D
-
Just LOL for the variables in Italian :P I am Italian too :) Glad that you sorted it!
-
it's hard to duplicate some variables this way ;)