7 Replies Latest reply on Dec 6, 2006 2:26 AM by Newsgroup_User

    CFLOCATION and Directory level

    smartino
      Hi, I have a cfm page that has a flash movie inside it.

      In the flash movie I use GETURL to redirect to another cfm page which i'll call page2 for this explanation. Inside page2 I have a cflocation tag that finds a cfm page two levels up the directory chain and I'll call this page page3. The code I us to go up 2 levels is ‘../../page3.cfm’ but the error I get back from CF is that CF trying to find page3 in the same directory as page2.

      Can anybody give me a pointer on why and how to solve this.

      Thanks in advance for any help.

      Cheers Simon
        • 1. Re: CFLOCATION and Directory level
          Dan Bracuk Level 5
          If relative addressing does not work, try absolute addressing.
          • 2. Re: CFLOCATION and Directory level
            CF_N_Montreal Level 1
            Agreed. Start from the root and you can't go wrong with that.
            • 3. Re: CFLOCATION and Directory level
              sean69 Level 1
              I like to set an application variable in my application file and just set everything "absolutely" from there.

              application.ServerRoot = "#Replace(GetCurrentTemplatePath(), "/Application.cfm", "", "all")#";

              it works quite nicely.
              • 4. Re: CFLOCATION and Directory level
                Level 7
                Bare in mind that the URL in the <cflocation> tag is relative to the URL of
                the request (and each relocate is a new request), and does not -
                necessarily - have any bearing on the relative filesystem paths between the
                file with the <cflocation> tag in it and the target of the <cflocation>
                tag.

                It doesn't sound - from your description - that this is your problem, but
                it's worth being mindful of.

                Why are you bouncing "through" page2.cfm, only to end up going to page3.cfm
                instead?

                --
                Adam
                • 5. CFLOCATION and Directory level
                  BKBK Adobe Community Professional & MVP
                  What you wish to achieve should be possible if your code and path structure is something like

                  code <cflocation url="page2.cfm"> in
                  C:\CFusionMX7\wwwroot\dir1\dir2\pageContainingFlashMovie.cfm

                  code <cflocation url="../../page3.cfm"> in
                  C:\CFusionMX7\wwwroot\dir1\dir2\page2.cfm

                  C:\CFusionMX7\wwwroot\page3.cfm

                  However, if instead you have

                  C:\CFusionMX7\wwwroot\pageContainingFlashMovie.cfm
                  C:\CFusionMX7\wwwroot\page2.cfm
                  C:\CFusionMX7\wwwroot\dir1\dir2\page3.cfm

                  then the code you should use in page2.cfm to redirect to page3.cfm is
                  <cflocation url="dir1/dir2/page3.cfm



                  • 6. Re: CFLOCATION and Directory level
                    smartino Level 1
                    Thanks for all your replys,

                    Dan and CF_N_Montreal I’ve done that and that seemed to work.

                    Sean69, I have used GetCurrentTemplate and other Directory code in the past. I think I should continue using this where I can.

                    Adam, the reason I’m bouncing through page2 is that it has a standard routine in it. I could or should use cfIncluded maybe. This might work better I don’t know.

                    BKBK, Correct - I thought it should work this way and this is why I continued in trying to find out the problem.

                    I don’t know if this has any bearing on my problem but I had a missing DOCTYPE tag in my page. I put one in and the page worked!?!?

                    I will keep mypath ../../ for the moment, but once I get even one error page come through I’ll switch to one of the methods mentioned in this thread.

                    Cheers.
                    • 7. Re: CFLOCATION and Directory level
                      Level 7
                      > Adam, the reason I?m bouncing through page2 is that it has a standard routine
                      > in it. I could or should use cfIncluded maybe. This might work better I don?t
                      > know.

                      <cflocation> does another trip back to the client browser, which you almost
                      certainly don't want. It's NOT a form of "goto" statement (and if it was,
                      you still shouldn't be using it in this case ;-), nor is it a way of
                      including code. So, yes, you should be using <cfinclude> or <cfmodule> or
                      something like that instead.

                      --
                      Adam