Limited time message

This mod creates a temporary message in a place of your choosing.



Create 2 language variables:





temp_message = “Your message”

temp_message_end_date = “end date”



The end date must have the format “mm/dd/yyyy” and you’ll need a different set of variables for each message placeholder you wish to create.



Create a new php file called “function.date_diff.php” in the “/skins/classes/templater/plugins/” folder with this code:



```php

/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: date_diff
* Version: 1.0
* Date: May 10, 2008
* Author: Matt DeKok
* Purpose: factor difference between two dates in days, weeks,
* or years
* Input: date1 = "mm/dd/yyyy"
* date2 = "mm/dd/yyyy" or $smarty.now
* assign = name of variable to assign difference to
* interval = "days" (default), "weeks", "years"
* Examples: {date_diff date1="5/12/2003" date2=$smarty.now}
* {date_diff date1="5/12/2003" date2="5/10/2008"}
* -------------------------------------------------------------
*/
function smarty_function_date_diff($params, &$smarty) {
$date1 = mktime(0,0,0,1,1,2000);
$date2 = mktime(0,0,0,date("m"),date("d"),date("Y"));
$assign = null;
$interval = "days";

extract($params);

$i = 1/60/60/24;
if($interval == "minutes") {
$i = 1/60;
} elseif($interval == "weeks") {
$i = 1/60/60/24/7;
} elseif($interval == "years") {
$i = 1/60/60/24/365.25;
}

if(substr_count($date1,"/")) {
$d1 = split("/",$date1);
} else {
$d1 = split("/",date("m/d/Y",$date1));
}
$date1 = mktime(0,0,0,$d1[0],$d1[1],$d1[2]);
if(substr_count($date2,"/")) {
$d2 = split("/",$date2);
} else {
$d2 = split("/",date("m/d/Y",$date2));
}
$date2 = mktime(0,0,0,$d2[0],$d2[1],$d2[2]);
if($assign != null) {
$smarty->assign($assign,floor(($date2-$date1)*$i));
} else {
return floor(($date2-$date1)*$i);
}
}
?>

```



Wherever you wish to create a temporary message add this code:


```php

{date_diff date1=$lang.temp_message_end_date date2=$smarty.now assign=“diff”}

{if $diff <= 0}

{$lang.temp_message}

{/if}
```

You can replace class-name with name of a class you create for your temporary message.

Okay, the last method couldn’t calculate difference between days, this method will by creating a new date_diff smarty function.

Here’s a few more good functions/ideas:



Business Day Calculations

[URL]http://planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=859&lngWId=8[/URL]



COMPLETE SMS WEBSITE

[URL]http://planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=2296&lngWId=8[/URL]



[COLOR=black]SlideCrab Flash Slideshow Generator and Safeguard (Requires Zend Optimizer PHP Plugin)[/COLOR]

[URL]http://planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=2219&lngWId=8[/URL]



[COLOR=black]Zip code (zipcode) range and distance calculation class v1.1.0 (*** UPDATED! Much Faster!)[/COLOR]

[URL]http://planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=1680&lngWId=8[/URL]