I’m converting a Drupal site that uses the ‘domain’ module, which allowed us to have one site and database, but multiple ‘domains’ which acted as a filter for displaying content (articles, menus, files, etc).
This allowed us to have subdomains, or subdirectories (either were supported) for automatically filtering the content. For us, ‘domain’ referred to ‘region’ so we had a site.com/us (or us.site.com) and site.com/eu (or site.com/eu) that would filter all the views of content, and content could be ‘syndicated’ across multiple domains as chosen by the editors (called ‘syndicated’). Additionally, different domains(regions) could have different page layouts and different blocks of content.
So, in meteor I replicated this on all the documents in all collections with a simple field on each document that is an array of regions the document is ‘syndicated in’.
Initially, I thought I would use FlowRouter and just set up routes for each region (domain), but as a test, I setup a session variable to accomplish the same.
Then in the relevant template helper function, it pulls the domain session variable and filters content in the relevant helper function.
That worked pretty well and was super fast to develop, but there are a couple of problems:
-Session variables are easy to lose, during development at least, and I would often discover the variable just unset. I understand there are some persistent-session packages that could alleviate this.
-When a user selects a new domain/region from my ui, the changes that occur are ‘too fast’ and disconcerting. Since it isn’t moving to a new route, stuff just magically ‘changes’ and it isn’t super apparent to the user. There is no ‘page reload’, just templates updating content.
- It seems less ‘automatic’ than I want, and every template has to check the session variable (maybe no way around that), so there is a lot of code duplication and boilerplate.
The other alternative would be to set up flow router to handle it, but I’m not sure if it makes it any easier at the template level. I already have route groups for ‘anonymous users’, ‘authenticated users’ and ‘admin users’ (based on role). I suppose I could create a new route group for ‘domain’, but is that the way to handle it? Do I then need to check flowrouter parameters in every interested template? Should the flowrouter group just set a session variable and then let the templates investigate that?
Should I setup different publications to handle this? Or maybe domain-specific subscriptions to content? If a re-usable template subscribed to one collection via a domain specific meteor function call, where/how does that subscription change when a user changes a route/session variable is set?
anyway, sorry for the rambling post, I just wanted to see if there were some better ideas out there.
thanks,
Cliff