5 Replies - 2568 Views - Last Post: 26 June 2014 - 08:36 AM Rate Topic: -----

#1 _WolfShade_  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 12-May 14

ExpandPath() and Application.cfc

Posted 20 May 2014 - 05:46 AM

Hello,

I'm mapping a component folder in my Application.cfc, like so:
this.mappings['/cfc'] = ExpandPath('.');


As long as I'm accessing a component from a CFM file in the root, it works excellent.

However, if I access from a sub-folder, the mapping is relative to the template, not the root.. so calling a component from, say, /admin will then show that the mapping is [whatever]/admin - and then it can't find the component.

What is the best way to dynamically set a mapping that will remain consistent from folder to folder, without putting an Application.cfc in every folder?

EDIT: I should mention that I'm trying to dynamically set the folder access, so I don't have to keep changing it between dev and production.

V/r,

^_^

This post has been edited by _WolfShade_: 20 May 2014 - 05:54 AM


Is This A Good Question/Topic? 0
  • +

Replies To: ExpandPath() and Application.cfc

#2 _WolfShade_  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 12-May 14

Re: ExpandPath() and Application.cfc

Posted 20 May 2014 - 07:16 AM

It ain't pretty, but it works.


<cfset this.mappings['/cfc'] =
"#REreplaceNoCase(ExpandPath('.'),'(.+[\\|\/]lastFolder[\\|\/])(.)+','\1','all')#">


V/r,
^_^
Was This Post Helpful? 1
  • +
  • -

#3 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 2024
  • View blog
  • Posts: 3,609
  • Joined: 13-January 08

Re: ExpandPath() and Application.cfc

Posted 20 May 2014 - 06:18 PM

I've only used dynamic mapping once. The vast majority of the time I simply access the CF administrator and set the mapping there.
Was This Post Helpful? 0
  • +
  • -

#4 _WolfShade_  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 12-May 14

Re: ExpandPath() and Application.cfc

Posted 21 May 2014 - 06:15 AM

And I can do that in my local dev install, but not the community dev install, nor the production. And around here, getting changes like that implemented is extremely difficult. Security is so tight, I'm amazed (sometimes) that any data gets through.

V/r,

^_^/>
Was This Post Helpful? 0
  • +
  • -

#5 _WolfShade_  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 12-May 14

Re: ExpandPath() and Application.cfc

Posted 26 June 2014 - 06:21 AM

Updated and added one for FQDN URLs:

<!--- This is for HD file path: C:\blah\bleh\meh\etc\LAST_FOLDER_NAME\oneMore\ --->
<cfset this.mappings["/LFN"] = "#REreplaceNoCase(ExpandPath('.'),'(.+[\\|\/]LAST_FOLDER_NAME[\\|\/])(.)+','\1','all')#">
<!--- Becomes "C:\blah\bleh\meh\etc\LAST_FOLDER_NAME\" --->

<!--- This is for FQDN URL: http://www.blah.com/LAST_FOLDER_NAME/stories/bleh/meh/ --->
<cfset application.app_base = "#REreplaceNoCase(cgi.script_name,'^(.+)(LAST_FOLDER_NAME\/)(.*)$','\1\2','one')#">
<!--- Becomes "http://www.blah.com/LAST_FOLDER_NAME/" --->



V/r,

^_^
Was This Post Helpful? 1
  • +
  • -

#6 _WolfShade_  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 12-May 14

Re: ExpandPath() and Application.cfc

Posted 26 June 2014 - 08:36 AM

Correction: NOT FQDN URLs, since cgi.script_name starts AFTER the domain name and TLD. My bad. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1