Reputation: 65
I'm building this website in ASP.Net MVC that basically will have a default look. Depending of the institution entering the portal the color, banner and greetings will change.
Example: www.portal.com/Institution1
Color: Blue
Banner: Photo1
www.portal.com/Institution2
Color: Green
Banner: Photo2
I'm trying to accomplish this in the BundleConfig.cs file but I haven't found a solution.
If somebody enter the portal using www.portal.com I will use:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
If somebody enter the portal using www.portal.com/Institution1 I want to use:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/Institution1/Institution1.css",
"~/Content/site.css"));
If somebody enter the portal using www.portal.com/Institution2 I want to use:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/Institution2/Institution2.css",
"~/Content/site.css"));
Is there any way of accomplished this?
Upvotes: 3
Views: 2177
Reputation: 15175
There is not one specific way to do this. I did something similar a few years back. You can define a set of themes and associate users or organizations with a known theme. The bundle name could be used like an identifier. If you layout your content in a manageable way then you can associated a user or organization with a style or theme from wherever you pull your content. After a user is authenticated generically, you could set a property on an IndexModel, or whatever, so that when the main page loads you can access the needed style using something like:
@Styles.Render(@Model.CurrentSyle.BundleName)
I would do something like:
public static void RegisterBundles(BundleCollection bundles)
{
//perhaps something like.
foreach (MyTheme theme in ThemeController.SelectAll())
AddThemeStyleBundle(bundles, theme.BundleName, theme.ThemeName);
}
private static void AddThemeStyleBundle(BundleCollection bundles,string bundleName, string themeName)
bundles.Add(new StyleImagePathBundle(bundlename).Include(
"~/Content/bootstrap.css",
String.Format("~/Content/{0}/Institution.css",themeName),
"~/Content/site.css"));
}
Upvotes: 1