• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Automated method to create subsites

Community Beginner ,
Feb 27, 2008 Feb 27, 2008

Copy link to clipboard

Copied

We are creating subsites by creating new subdirectories and using a separate application.cfm and include files.
www.mysite.com/subsite1
www.mysite.com/subsite2

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.
TOPICS
Advanced techniques

Views

416

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Feb 28, 2008 Feb 28, 2008
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 la...

Votes

Translate

Translate
Explorer ,
Feb 28, 2008 Feb 28, 2008

Copy link to clipboard

Copied

Hi,
You can use the CGI.SCRIPT_NAME variable and use the listfirst function to get the text you require.

-Prasanth

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 28, 2008 Feb 28, 2008

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 28, 2008 Feb 28, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 28, 2008 Feb 28, 2008

Copy link to clipboard

Copied

LATEST
Yes, this appears to work better. Using the cgi.servername I can get the subsite and use that in the query. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation