Professional Web Applications Themes

Ideas for sharing same code with 2 web sites - Coldfusion - Advanced Techniques

I'm working on a project where 2 web sites will each have a distinct look and feel, but I'd like to have them share the same code base, rather than just duplicating (and maintaining) two sets of .cfm files. I can put some application variables in application.cfm to define specific image paths, etc., but does anyone have suggestions on the best way to set up the physical directory structure so each site has it's own application.cfm yet still drill down into the code base? I'll be using IIS 6.0 and will have a different domain name for each site, e.g. ...

  1. #1

    Default Ideas for sharing same code with 2 web sites

    I'm working on a project where 2 web sites will each have a distinct look and
    feel, but I'd like to have them share the same code base, rather than just
    duplicating (and maintaining) two sets of .cfm files.

    I can put some application variables in application.cfm to define specific
    image paths, etc., but does anyone have suggestions on the best way to set up
    the physical directory structure so each site has it's own application.cfm yet
    still drill down into the code base?

    I'll be using IIS 6.0 and will have a different domain name for each site,
    e.g. [url]www.site1.com[/url] and [url]www.site2.com[/url]. I'm sure I'm missing something obvious
    here....


    sugarstudio Guest

  2. #2

    Default Re: Ideas for sharing same code with 2 web sites

    Um point both the domains to the same directory in IIS.
    pflynn02 Guest

  3. #3

    Default Re: Ideas for sharing same code with 2 web sites

    I'd start by suggesting you look into either Fusebox4 (or MachII if your more
    object oriented) as a basic architectural approach. We currently have about 50
    different sites running on one code base (only one root directory,
    application.cfm and index.cfm for all of them) using this methodology. Even if
    you don't think you need it now, it's good experience.

    Then I'd load up the different site settings from a database or xml file based
    on the domain name and set them to application variables and name your
    application something like: <cfapplication name="#cgi.server_name#">. Then
    always reference the site specific stuff like images as
    application.images.directory. If you need it, you can create a website specific
    directory structure like root\<website>\images or root\<website>\content.

    This should get you started in the right direction.

    Good Luck!

    Neo Rye Guest

  4. #4

    Default Re: Ideas for sharing same code with 2 web sites

    Neo, of course I can't find it now but I remember reading something buried in
    the Macromedia docs on application.cfm /cfc that you shouldn't put <cfif>
    statements in there as it's not always reliable.

    I had thought about keying off the CGI variable for the domain and setting the
    appropriate path variables etc. accordingly in application.cfm, but reading
    this note somewhere scared me off.

    Just curious if you've had experience with it working or not. Thanks for the
    guidance.

    sugarstudio Guest

  5. #5

    Default Re: Ideas for sharing same code with 2 web sites

    All I have in my application.cfm file is the following code:
    <cfif CompareNoCase(cgi.script_name, "/index.cfm")>
    <cflocation url="http://#cgi.server_name#/index.cfm" addtoken="no">
    <cfabort>
    </cfif>

    Neo Rye Guest

  6. #6

    Default Re: Ideas for sharing same code with 2 web sites

    Thanks Neo -- I'll give it a try and see if it works.
    sugarstudio Guest

  7. #7

    Default Re: Ideas for sharing same code with 2 web sites

    The simplest way: Put all of your common code into a folder named... /Common/

    Then create two web sites, each with its own web root. Put the UNIQUE files
    for each site into this web root. If a unique page needs to access a common
    file (i.e. [cfinclude template="common/myinclude.cfm"] make sure the 'common'
    folder is referenced in the link as shown above.

    In IIS, create a virtual directory mapping to the /Common/ folder.

    You can accomplish this in about 10 seconds if you hurry, or 30 seconds if you
    take your time :-).

    MattRobertson Guest

  8. #8

    Default Re: Ideas for sharing same code with 2 web sites

    On the server...have one main domain name. Then, inside that is a folder called / sites / and / admin /. The admin folder as where you and your users can log into to manage content.

    Within the sites folder is the root folders for all the domain names that share the application files.

    So...

    Code:
    www.MainDomain.com
        ADMIN    
        SITES
              www.asite.com
                   pageimages
                   sitefiles
                   index.cfm
              www.anothersite.com
                   pageimages
                   sitefiles
                   index.cfm
              www.anothersiteven.com
                   pageimages
                   sitefiles
                   index.cfm
        Application.cfm
        inc_settings.cfm
        inc_header.cfm
        inc_footer.cfm
    The index.cfm file sets the SITEID variable first. After that is set you can use cfinclude to retrieve the inc_settings.cfm and use the SITEID to get site settings. I store the DOMAIN NAME in the database based on the SITEID.

    The index.cfm page consists of only a few cfincludes to call the settings, header and footer files. My application reads a url variable which is a phrase like "about-us" or "contact-page" but could be "pageid" or whatever you want. I like uses phrases for SEO purposes.

    There are a few server set up things you'll have to consider. I am on Apache and create "Symbolic Links" in each directory that basically allow the sharing of the CFIDE folder between sites. I'm not sure if IIS has a similar option.
    JIP Guest

Similar Threads

  1. Sharing Code Snippets with team
    By JamieMason in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: March 9th, 12:16 PM
  2. Remove code form all sites in one swope??
    By Reven39 in forum Macromedia Dynamic HTML
    Replies: 3
    Last Post: March 7th, 04:26 PM
  3. Sharing UserControls between different sites
    By Anders K. Jacobsen [DK] in forum ASP.NET Building Controls
    Replies: 4
    Last Post: December 8th, 11:35 PM
  4. Sharing code
    By david_francois_huynh@adobeforums.com in forum Adobe Indesign Windows
    Replies: 3
    Last Post: April 13th, 10:43 AM
  5. Sharing a shopping cart between 2 sites...
    By CanardWC in forum PHP Development
    Replies: 1
    Last Post: October 28th, 01:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139