Optional Paramaters in CFScript Function
I usually use CFFUNCTION for things like this, but in this case I have existing code. The code builds a self-expiring "New" tag for new (or updated) items on our website. The code looks like this:
<cfscript>
function newtag(type,date){
if (type IS "n") msg = "New: ";
else if (type IS "r") msg = "Revised: ";
else msg = "Updated: ";
if(datediff("d",date,now()) lt 90)
WriteOutput(' <span class="hilite">' & msg & date & '</span>');
}
</cfscript>
It works well, but it's hard-coded for 90 days. While this works most of the time, I have occasionally been asked to extend it by 30 or 60 days.
I've tried adding a 3rd parameter for the expiry, like this:
function newtag(type,date,exp){
But that ends up making the 3rd function required, and I don't want to have to sift through 70,000+ pages to update every place the function is called on. Is there any way to include that 3rd argument and make it optional? Or assign it a default value if it's not passed?
