This will work for a few domains, but if you end up running a few hundred (or thousand) sites off of one codebase this will get to be a maintenance nightmare.
Steve 'Cutter' Blades Adobe Certified Expert Advanced Macromedia ColdFusion MX 7 Developer ____________ http://blog.cutterscrossing.com Co-Author "Learning Ext JS 3.2" Packt Publishing 2010 https://www.packtpub.com/learning-ext-js-3-2-for-building-dynamic-desktop-style-user-interfaces/book "The best way to predict the future is to help create it" On 2/17/2011 12:10 PM, Jason Fisher wrote: > I usually use CFSWITCH and assign my own app names, which allows me to use > the built-in list nature of CFCASE values: > > > <cfswitch expresssion="#cgi.server_name#"> > <cfcase value="domain.com,www.domain.com"> > <cfset appName = "domain" /> > </cfcase> > <cfcase value="mydomain.com,www.mydomain.com"> > <cfset appName = "mydomain" /> > </cfcase> > <cfcase value="blog.domain.com"> > <cfset appName = "domainBlog" /> > </cfcase> > </cfswitch> > > > etc etc ... that way my onApplicationStart is basically mapping 1-to-1 with > my application config table, but I can throw as many domain variations at > it as I want to. > > > > ---------------------------------------- > > From: "Mark A. Kruger"<[email protected]> > Sent: Thursday, February 17, 2011 12:59 PM > To: "cf-talk"<[email protected]> > Subject: RE: Feedback on this approach to "many sites, one codebase" > (MSOC) > > Ooh... good point Russ. I usually strip off the "www" and replace the > periods with underscores as well. That way I have only 1 app name per > domain. So www.coldfusionmuse.com would be coldfusionmuse_com (don't like > those periods in variable names). > > -Mark > > -----Original Message----- > From: Russ Michaels [mailto:[email protected]] > Sent: Thursday, February 17, 2011 11:45 AM > To: cf-talk > Subject: Re: Feedback on this approach to "many sites, one codebase" > (MSOC) > > For a primae example of how this is best done you can look at many of the > major frameworks which support this type of setup. > MACH-II for example allows you to have a single core install of the > framework which is used by all your apps via a simple mapping. > > If you plan to use the domain name to create the application name and > track > sessions and users and what not, then you also need to allow for the fact > that the site may be accessed via multiple domains (domain.com, > www.domain.com and aliases) or build in automatic redirection so that this > doesn't happen. > > Russ > On Thu, Feb 17, 2011 at 5:28 PM, Rick Faircloth > <[email protected]>wrote: > >> Hi, all... >> >> I've been tinkering around the edges with >> "many sites, one codebase" (MSOC) for awhile and >> was interested in getting some feedback on an >> approach I'm taking. >> >> The most basic part is that I use the domain name >> to determine variable values for a site. >> >> I'll start with that. >> >> I use application.cfc to set up the following: >> >> <cfset this.name = "#cgi.server_name#"> >> >> Any issues with that? >> >> Then I have use the onApplicationStart cffunction to >> clear session and application variables. >> >> Then I use the cgi.server_name, determined from the >> URL visited by a user, of course, and run this query to get needed >> values for site variables from a database: >> >> <cfquery name = "qGetApplicationVariables" > datasource="globalSiteManager"> >> select * >> from siteApplicationSettings >> where (select strcmp(siteName, '#cgi.server_name#')) = > -1 >> </cfquery> >> >> Then, I set site variables as follows: >> >> <cfset application.dsn = >> "#qGetApplicationVariables.applicationDSN#'> >> etc... >> >> At this point, I'm entering all a site's variables into a database >> manually, >> although if I continue with this approach, I'll develop an automated >> solution. >> >> The site menu is determined also by values in a database for the site >> by using code such as the following: >> >> <cfset application.calendar = >> '#qGetApplicationVariables.applicationCalendar#'> >> >> If the qGetApplicationVariables.applicationCalendar value is 'yes', then >> the >> menu item is shown, if it's 'no', then the menu choice is not shown. >> >> The last piece of this approach is setting path variables, etc, for > image >> and >> document uploads, image paths, etc, with this type of code: >> >> <cfset application.userImagesPathAbsolute = >> '#qGetApplicationVariables.applicationUserImagesPathAbsolute#'> >> etc. >> >> This seems to be working fine so far... speed is good, etc., >> but I'd like to know, from those of you who have been down this road >> before, >> if I'm heading for a show-stopping issue, or if this is a workable >> solution. >> >> And, I'm really not interested in frameworks...not at this point. >> >> Thanks for taking the time to read this and offer any feedback. >> I'm just ready to develop some applications that I can sell *more than >> once*!! >> "Work smarter, not harder" approach. Watching people getting rich > selling >> apps for $.99, such as "Angry Birds", is just killing me. I thought, >> surely >> there has got to be a better way to be a freelancer than "one-off" >> projects! >> >> Rick >> >> >> >> > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342460 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

