SimplePortal
Customization => Custom Coding => Topic started 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?
-
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?
-
2.0 RC 1.2 presently. with Simpleportal 2.3.1
-
After working a couple of weeks, I finally figured out the code to do this.
In a custom PHP block enter:
<?
//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$expiry = strtotime("1/10/2010");
to the date you want to set the block to expire....
replace$expiry = strtotime("1/12/2010");
then place your HTML between the
<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>"
if ($today > $expiry) {
$new_status = '<p><html> //////HERE\\\\\ </html></p>';
} else {
$new_status =