SimplePortal

Customization => Custom Coding => Topic started by: TW1ST3D on December 24, 2009, 12:52:49 PM

Title: Expiration Date/Time for Blocks
Post by: TW1ST3D on December 24, 2009, 12:52:49 PM
First of all let me tell you that Simpleportal is the Greatest Portal for SMF !!

However, I found a need for an Expiration Date for my center blocks. Is there a way to code this to include a time for showing the box and a time to turn it back off? an example would be a Merry Christmas announcement that you want to be shown December 24th 12:01am  through December 26th 12:01 am.

I think this would be a great function to have. It would allow a sort of "Auto-pilot" for our forum.

What do you guys think?
Title: Re: Expiration Date/Time for Blocks
Post by: Nathaniel on December 25, 2009, 08:43:29 PM
Moved to the Custom Coding board.

It would be easiest to do this with a custom PHP block, which version of SMF are you using?
Title: Re: Expiration Date/Time for Blocks
Post by: TW1ST3D on December 26, 2009, 11:17:20 AM
2.0 RC 1.2 presently. with Simpleportal 2.3.1
Title: Re: Expiration Date/Time for Blocks
Post by: TW1ST3D on January 09, 2010, 05:57:37 PM
After working a couple of weeks, I finally figured out the code to do this.

In a custom PHP block enter:

Code: [Select]

<?
//set your link expiration date here.
$expiry = strtotime("1/10/2010");
$today = strtotime("now");

if ($today > $expiry) {
$new_status = '<p><html></html></p>';
} else {
$new_status =

'<p>
<html>

</html>
</p>';
}
echo $new_status;
?>


Then change your date:
find
Code: [Select]
$expiry = strtotime("1/10/2010");
to the date you want to set the block to expire....
replace
Code: [Select]
$expiry = strtotime("1/12/2010");

then place your HTML between the

Code: [Select]
<html>

</html>

Tags.


It works GREAT!!  This has unlimited uses for anything that you can put in a block whether it be in a left, right or center block!

You can even set it display something else when the original item expires if you place it between the top set of "<p><html>  <html></p>"
Code: [Select]
if ($today > $expiry) {
$new_status = '<p><html>  //////HERE\\\\\  </html></p>';
} else {
$new_status =
SimplePortal 2.3.8 © 2008-2024, SimplePortal