2

I am new to Mura and have a lot of existing code that I am trying to utilize. I have a globalFunction.cfc file that has a lot of functions that I need to have access to for the existing code. Previously I always extended my application.cfc to the global function so they where always there. With Mura I am not sure where to include it and still keep the installation "upgrade safe".

Any suggestions are appreciated.

Lance
  • 3,193
  • 2
  • 32
  • 49

2 Answers2

1

In your [site]/includes folder is an Application.cfc. I believe that is the one you are looking to have extend your globalFunction.cfc. It is update safe.

Jason Dean
  • 9,585
  • 27
  • 36
  • Jason, I tried that but it doesn't seem to be firing that application.cfc. It isn't on the showTrace list and if I put bad code in it (on purpose) it doesn't cause an error so I am pretty sure it isn't being called – Lance Aug 30 '12 at 22:07
  • 1
    Ah, it looks like that App.cfc only gets called in some situations. Specifically when something is executed directly from that folder. Apparently templates are not executed from that folder (even though they are in it). – Jason Dean Aug 31 '12 at 18:10
0

Lance,

You can just put any functions you're wanting to use throughout your site in your eventHandler or contentRenderer files in your theme's folder. These are update safe, and depending on how you're wanting to use them, you can use one for display and the other for function.

EventHandler Ex:

<!--- PAGE - Default  --->
<cffunction name="onPageDefaultBodyRender" output="true" returntype="any">
    <cfargument name="$">
    <cfif $.getcontentID() neq "00000000000000000000000000000000001">#$.dspInclude('/themes/MYTHEME/display_objects/bodies/dsp_body_default.cfm')#</cfif>
</cffunction>

ContentRenderer Ex:

<cffunction name="removeLinks" returntype="string" access="public">
    <cfargument name="str" default="" required="true">

    <cfset str=reReplace(str, "<[[:space:]]*[aA].*?>(.*?)<[[:space:]]*/[[:space:]]*a[[:space:]]*>","\1","all") />

    <cfreturn trim(str) />
</cffunction>

The EventHandler here just puts out an different body if its on the home page, where the contentRenderer removes any links if i use $.removeLinks(MYURLSTRING).

HTH