4

Im building a Grails app that will have multiple similar websites (each it's own domain name) with the same code but different design and configuration. (think of blogger)

What is the best method for using different view and even some different logic on a single app without too much hacking?

I'm new to Grails and the method I have in mind is to check all the time to see what the domain name is and to serve the right controller/view. Is there a better way?

cripox
  • 556
  • 1
  • 7
  • 19
  • I was actually considering asking a nearly identical question yesterday. If you test out the MultiTenant plugin would you mind reporting back on your experience? I know on the plugin page it says its in alpha state and claes indicated it's only compatible with 1.2 so not a viable option for me right now, but I would love to know how it works out for you (if it's not too much trouble). – chrislatimer Jul 07 '10 at 13:39
  • If I will use it I will put here an update. But I got a little worried about the same issues and I need it for a high traffic production website, so... I don't know if to use it. – cripox Jul 07 '10 at 17:58
  • Many Grails plugins don't turn out to be an "out-of-the-box" solution for your requirements. However, they are easy to unzip and inspect and modify or enhance if needed. I suggest you spend a few hours digging into the source code rather than begin to develop something from scratch. Have a look here... http://grails.1312388.n4.nabble.com/Support-for-multi-tenant-in-grails-1-3-1-td2277982.html ...about the state of the plugin and maybe you can help out once you get a grip of it. I might as well if I start to use this plugin :-) – wwwclaes Jul 07 '10 at 19:04

1 Answers1

2

I would have a go with the MultiTenant plugin. You mention that views and logic differ, but I'm guessing what will differ most is the data? Use MultiTenant to cleanly separate the data for each site without too much hazzle, and if you store the configuration of views and logic in the DB you get that unique per site as well.

I think MultiTenant is being updated to the latest Grails release, at least I've seen that mentioned in the Grails mail list. I think you need to use an 1.2 release until then.

I'm doing something similar to separate data using the Hibernate Filter plugin. My views are the same but I have per-site texts and messages by looking up message "SITE-A.hello.world" first and if not found the default message "hello.world" is retrieved. Just to give you an idea how views may be customized, though you probably need to take it further than that for your system...

wwwclaes
  • 1,152
  • 8
  • 12