ModelGlue:3 has the notion of ViewMappings. ViewMappings are an ordered list
of where ModelGlue should look to find a specific view. It will look in
order and use the first one it finds. This means if you have your
viewMappings set to:
"/CustomSite,/DefaultSite

and the request calls Form.Login.cfm, ModelGlue will look for
/CustomSite/Form.Login.cfm and if that file exists, serve content from that
fiel. If it does not exist, it will look for /DefaultSite/Form.Login.cfm and
use that one.

The fun part is the viewMapping is put into the event (EventContext) and can
be manipulated at runtime. Suppose you had a multi-tenant site where you had
10 URLS all using the same code base with different layout/graphics/etc. You
can interrogate the environment (hostname, parameters, whatever) and prepend
a path to the ViewMappings at will.  Example:

A request comes from http://ilovegoats.com
Your code needs to serve views from a directory called /iLoveGoats_WWW
You run code on the ModelGlue.onRequestStart event to figure this out and
prepend /iLoveGoats_WWW to the view mapping.

*<cfset customViewMappings = returnILoveGoatsInThisExample() />*
*<cfif len(customViewMappings)>**
   **<cfset viewMappings = event.getValue(**"viewMappings"**) />**
   **<cfset arrayInsertAt(viewMappings,** 1**, customViewMappings) />**
   **<cfset event.setValue(**"viewMappings"**, viewMappings) />**
* *</cfif>*


Then your views will magically pull from /iLoveGoats_WWW for that request.

Compact, yet stylish yeah?


DW




On Thu, Jun 25, 2009 at 11:25 AM, Jeff Gladnick <[email protected]>wrote:

>
> They share the exact same code base - we didn't want to have to make
> any changes whatsoever to the code base for different sites.  the only
> difference are settings for each site are loaded from a database, and
> they have their own css file.
>
> On Jun 24, 5:22 pm, Baz <[email protected]> wrote:
> > Also, what's the relationship between the domains? Are they completely
> > separate but just share similar code so that if you literally copy/pasted
> > all your code for each domain they would still work as expected? Or does
> one
> > domain sometimes need to share data with another domain?
> >
> > Baz
> >
> > On Wed, Jun 24, 2009 at 5:17 PM, Baz <[email protected]> wrote:
> > > I don't think that duplicating all the cfc's nor passing the SiteID
> into
> > > every function call are the optimal solutions. Can you give a bit more
> > > detail on your setup, with some examples of functions that you would
> pass
> > > the SiteID into.
> >
> > > For example, as an extremely simplified model, could we say that you
> have
> > > sub1.jeff.com and sub2.jeff.com, which are identical sites except that
> > > their titles are different? Then to get their titles you would want to
> do
> > > getTitle() but to make sure you get the right one you are thinking of
> doing
> > > getTitle('sub1') and getTitle('sub2'). If that's the case, then you're
> > > screwed - just kidding, but is that kind'of what you're talking about?
> >
> > > Baz
> >
> > > On Wed, Jun 24, 2009 at 4:15 PM, jeff <[email protected]> wrote:
> >
> > >> I have to make an application where multiple domains (or subdomains)
> > >> should be using the same code base.  Previously, the way I did this
> > >> was create a new model glue “application” instance for each unique
> > >> domain.
> >
> > >> Then in the init() method of controller.cfc, we would
> > >> 1)      Get the unique siteID out of the database based on the domain
> name
> > >> 2)      Instantiate all of the CFCs to the variables scope by passing
> in
> > >> the unique siteID
> >
> > >> Looking back, this seems kind of wasteful, and it seems like it would
> > >> be easier to somehow save the siteID to session or something and pass
> > >> then into EVERY function call instead of creating duplicate cfcs.
> > >> Anyone have any recommendations for how to go about this best?  Will
> > >> this make programming it way more complex?
> >
>


-- 
“Come to the edge, he said. They said: We are afraid. Come to the edge, he
said. They came. He pushed them and they flew.”

Guillaume Apollinaire quotes

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to