What are techniques you use to show different features / versions of your EE site to different users?
I use "feature flag" techniques in my client-side Javascript (my Javascript Feature Flags library is a temporarily out-of-date example), and want to enable something(s) similar in EE. Scenarios I'd like to support--e.g., on a live, production site, at the same URL:
- allow developers to see different templates than regular users
- allow developers to see different content than regular users
- allow user group A to see one feature, and user group B to see a different feature (e.g., A/B testing, or gradual rollout of new features)
The obvious EE technique that comes to mind is having simple "router" templates, that conditionally embed other templates. Like:
{if member_id==1} {!-- ideally, abstracted to {if dev==1} --}
{embed="developer/index"}
{if:else}
{embed="production/index"}
{/if}
I could imagine abstracting that, such that I could set a global feature flag that is triggered by specific conditions (specific member_id, group_id, ip_address or a cookie value). Using Freebie, one could use URL segments as trigger, as well.
I've done this kind of thing on an ad hoc basis within a template, but I'm curious if others have done anything like this, systematically. If so, what technique(s) have you used? Have you found it useful and maintainable over time?
Updated: ideas for ad hoc techniques are appreciated. But I'm especially interested to know of any systematic approaches being taken, and their relative pros / cons for maintainability and ongoing usefulness.
For example, is there some code you make available to every template that allows you to switch things on and off across many templates? Is there an add-on or htaccess technique that gives you top-level control over routing, that allows you to conditionally set routes (based on user, cookie, ip address, etc.)?