Andy Jarrett // Code. Develop. Create.

UDF file in Model Glue

This has just came up on the MG Lists and I thought i should post my solution on how I implement a UDF file in MG1)My UDF file is a component (cfc) on the root of the site. Example UDF:
<cffunction name="getDateTime"> <cfreturn now() /></cffunction>
2)Then in my controller (in the onRequestStart):
<cfset variables.udf = createObject("component","pathTo.udf").init()><cfset arguments.event.setValue("udf", variables.udf)>
3)On my view page I have<cfset udf = viewState.getValue('udf') />
Then to call a function<cfoutput>#udf.getDateTime()#</cfoutput>

I’m here, learning and working away. If you liked this content and want to keep me going, consider buying me a coffee. Your support keeps this site running and the coffee brewing! ☕️