#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    111
    Rep Power
    16

    Pull my header from another domain


    So as it stands right now I've got several domains. One with my live site, the other with the back end. They are both on the same server(IIS7.5) but separate sites.

    I've developed a nifty little editing tool on the back end site and would like to load the header and footer from my live site around it... so it looks like your editing stuff on the live site.

    I've created a virtual directory and mapped it to the root of my live site. The problem is i'm using <CFINCLUDE> on my live site and the directory paths are now pointing to the backend and this is throwing file not found errors.

    Is there a better way to accomplish what i'm trying? if not how can I work around this CFINCLUDE issue?

    Thanks,
    DSFX.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    It sounds like you want to set up one or more mappings in the CF administrator, so that a given path always points to the same location on disk. The docs talk about this, but it is fairly self-explanatory.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    111
    Rep Power
    16
    Originally Posted by kiteless
    It sounds like you want to set up one or more mappings in the CF administrator, so that a given path always points to the same location on disk. The docs talk about this, but it is fairly self-explanatory.
    Thanks Kiteless,

    I'll try to play around with it this week, it seems pretty straight forward.

    DSFX
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    111
    Rep Power
    16
    ok so I've set up a test mapping /test (creative I know).
    It's mapped to the root of my public website c:/inetpub/wwwroot/


    When I use it in a CFINCLUDE template="/test/header.cfm" in my intranet site at c:/inetpub/intranet it gives me errors in my header.cfm(which has cfincludes in it) saying it can't find the files in those includes. Should the mapping not remap these since they are being loaded via a mapping?

    This is a bit convoluted.... I apologize.
  8. #5
  9. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    No, if the subsequent includes don't also use the mapping alias in their paths, it doesn't magically alter all the subsequent includes. There's no way it could. You'd need to use the same alias in those include paths as well. I assumed the reason you were asking about this is that all of your includes were using the same site-specific path and you just wanted to make sure they all pointed to the same physical location on disk.

    If the existing paths used on the different sites don't have a common path element that can be used as a CF mapping alias, the only real option is to change them. Because even if you decided to just duplicate the files across the different sites, you'd still have to change them to use whatever paths are valid for each site.

    So if the includes look something like "/layouts/header.cfm", you can set up a CF mapping so that "/layouts" always points to the same folder instead of an absolute path from one web root. But if the includes all look different, or use relative paths like "../../layouts/header.cfm", then a CF mapping won't work. You'd have to change them to use "/layouts" for the mapping to help.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    111
    Rep Power
    16
    Originally Posted by kiteless
    No, if the subsequent includes don't also use the mapping alias in their paths, it doesn't magically alter all the subsequent includes. There's no way it could. You'd need to use the same alias in those include paths as well. I assumed the reason you were asking about this is that all of your includes were using the same site-specific path and you just wanted to make sure they all pointed to the same physical location on disk.

    If the existing paths used on the different sites don't have a common path element that can be used as a CF mapping alias, the only real option is to change them. Because even if you decided to just duplicate the files across the different sites, you'd still have to change them to use whatever paths are valid for each site.

    So if the includes look something like "/layouts/header.cfm", you can set up a CF mapping so that "/layouts" always points to the same folder instead of an absolute path from one web root. But if the includes all look different, or use relative paths like "../../layouts/header.cfm", then a CF mapping won't work. You'd have to change them to use "/layouts" for the mapping to help.
    Thanks Kiteless,

    That's what I thought but before I put the effort into doing it I wanted to make sure.

    DSFX.
    Last edited by dsfx; November 1st, 2013 at 08:50 AM.
  12. #7
  13. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    Sure. This is why it's always a VERY good idea to avoid relative paths anywhere in an app, and to always use web-root-based paths (e.g. "/layouts/foo.cfm") for absolutely everything. cfincludes, HTML links, form actions, everything. You can even define application-level variables for parts of the path and use those in your paths (e.g. "#appRoot#/layouts/foo.cfm"). This way, when a situation like this comes up, it's easy to deal with.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    111
    Rep Power
    16
    Originally Posted by kiteless
    Sure. This is why it's always a VERY good idea to avoid relative paths anywhere in an app, and to always use web-root-based paths (e.g. "/layouts/foo.cfm") for absolutely everything. cfincludes, HTML links, form actions, everything. You can even define application-level variables for parts of the path and use those in your paths (e.g. "#appRoot#/layouts/foo.cfm"). This way, when a situation like this comes up, it's easy to deal with.
    That is a good suggestion. I'm going to incorporate this into all my sites from now on.

    The big problem with this site i'm working with right now is it was done in a hurry because our deadline got cut by 2 months, we lost our project lead and head programmer and there were language barrier issues on the team as well. Oh and we started 3 months late.

    All in all a mess which I have little time to clean up.
  16. #9
  17. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    Yeah, if the paths are all relative (which it sounds like they are but you haven't said specifically), this is harder.

    One thing you can try is to identify some common patterns and do a global search and replace using a text editor or your IDE.

    So if you always want the header includes to use "/layouts/header.cfm", but in the actual includes it uses things like "../layouts/header.cfm" and "../../layouts/header.cfm", etc., you can use a global find and replace. So you'd run one replace that finds all "../../layouts" and replaces them with "/layouts". Then again for "../layouts" and again replace with "/layouts". And so on.

    Obviously this is risky and you'll have to test the hell out of it to make sure all is well, but it could let you avoid having to manually go change them all.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    111
    Rep Power
    16
    Originally Posted by kiteless
    Yeah, if the paths are all relative (which it sounds like they are but you haven't said specifically), this is harder.

    One thing you can try is to identify some common patterns and do a global search and replace using a text editor or your IDE.

    So if you always want the header includes to use "/layouts/header.cfm", but in the actual includes it uses things like "../layouts/header.cfm" and "../../layouts/header.cfm", etc., you can use a global find and replace. So you'd run one replace that finds all "../../layouts" and replaces them with "/layouts". Then again for "../layouts" and again replace with "/layouts". And so on.

    Obviously this is risky and you'll have to test the hell out of it to make sure all is well, but it could let you avoid having to manually go change them all.
    Actually to be honest not that many are relative... it's rare. But a lot of stuff got dumped into the root. So i'm thinking I'll copy it all and organize it into folders outside of the site, create my mappings then change the code.

    I've got a lot of <CFINCLUDE template="/header.cfm"> and things like that in there.
  20. #11
  21. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    Yeah, the mapping alone won't work there. You CAN create a mapping for just "/", but obviously that would point anything in all the sites that start with "/" to the same directory, which you don't want since these are separate sites.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    111
    Rep Power
    16
    Originally Posted by kiteless
    Yeah, the mapping alone won't work there. You CAN create a mapping for just "/", but obviously that would point anything in all the sites that start with "/" to the same directory, which you don't want since these are separate sites.
    Yeah it was poor planning... or just an all together lack of planning that led to this. It's not a hard fix just a bit of a pain. It's mostly just the header and footer that i'll have to change so it's not the end of the world. If I get really ambitious I'll add a new virtual directory for the images to centralize everything.

    Thanks for the advice Kiteless.

IMN logo majestic logo threadwatch logo seochat tools logo