4 Replies Latest reply on Feb 28, 2008 11:44 AM by jaliu

    Automated method to create subsites

      We are creating subsites by creating new subdirectories and using a separate application.cfm and include files.

      Is there a way in coldfusion to automate this? I.e., map "subsite1", "subsite2", ... to a database column to determine which rows/content to render. The part that is unclear is how to capture the subdirectory and map it to a database column even if the subdirectory doesn't exist.
        • 1. Re: Automated method to create subsites
          Prasanth Kumar.S
          You can use the CGI.SCRIPT_NAME variable and use the listfirst function to get the text you require.

          • 2. Automated method to create subsites
            Neo Rye Level 1
            I'd do it differantly. Set up your DNS to point all (any) hosts to your domain, so someone could type anything as the host such as subsite1.mywebsite.com and subsite2.mywebsite.com. Then you only need one application.cfm where the name of the application is the domain name with cgi.server_name. You then define your sites in the database based on their unique URL. This is also handy if you need to break your busy sites accross multiple jrun instances or servers.

            You could then apply differant layout per application and differant config, directories etc. You can look at fusebox 5, since that framework can apply layouts based on variables.
            • 3. Re: Automated method to create subsites
              jaliu Level 1
              Thanks, I think that provides the solution. It appears subsites can be automatically created with the cfdirectory (create) and cffile (copy) to move stub/empty files over. The stub/empty files would just contain includes bringing in the original templates and specify which database rows to retrieve based upon the CGI.SCRIPT_NAME variable. This appears to work, but is there a better way to accomplish this?
              • 4. Re: Automated method to create subsites
                jaliu Level 1
                Yes, this appears to work better. Using the cgi.servername I can get the subsite and use that in the query. Thanks!