0 Replies Latest reply on Jul 24, 2009 4:39 PM by sean69

    Application.cfc & mappings.

    sean69 Level 1

      OK - is there a sexier way to do this? i.e. less code & more reliable?


      Lets assume:

      - the CFserver has no mappings defined

      - my application is in a subdirectory of a virtual host where the root directory has no cfmx files at all ["/Registration"]

      - application.cfc is new to me today

      - I need to filter every request through the onRequest method


      we know:

      - onRequest method arg "targetPage" gets the ~requested template from the http root~

      - a cfinclude needs either a ~relative path~ from the current template OR an abslute path from the server root.

      - [I'm just working my thoughts through here]


      ok - so I have in my Application.cfc


      this.mappings["root"] = Replace(getDirectoryFromPath(getCurrentTemplatePath()), "Registration/", "", "all");


      then in my onRequest method:


      <cfinclude template="#this.mappings['root']##arguments.targetPage#">


      so it works, [or so it seems] and always includes from the server root - but, is it right? is there a better way?