Git Product home page Git Product logo

aspnet.mvc.theming's Introduction

AspNet.Mvc.Theming

Enables implementing themes for ASP.NET MVC.

Build status

To install AspNet.Mvc.Theming,

Install-Package AspNet.Mvc.Theming

Area theme customization not implemented yet!

How to use;

Create Themes (or what you want) folder and put your themes to folder and initialize ThemeManager to use this folder to apply theme and set default theme;

 public class MvcApplication : System.Web.HttpApplication {
        protected void Application_Start() {
        
           //Omitted for brevity..

            ThemeManager.Instance.Configure(config => {
                config.ThemeDirectory = "~/Themes";
                config.DefaultTheme = "Other";
            });
        }
    }

Put Theme attribute to your controller to use theme you want.

 [Theme("Default")]
    public class WorkController : Controller
    {

        [HttpGet]
        public ActionResult Index()
        {
            return View(new WorkModel
            {
                Content = "Hello World!"
            });
        }

    }

Custom theme resolver

To implement your custom theme resolver see

Sample: SessionThemeResolver

   public class SessionThemeResolver : IThemeResolver
   {
        public string Resolve(ControllerContext controllerContext, string theme)
        {
            string result;

            if (controllerContext.HttpContext.Session != null && controllerContext.HttpContext.Session["Theme"] != null)
            {
                result = controllerContext.HttpContext.Session["Theme"].ToString();
            }
            else
            {
                result = (!string.IsNullOrEmpty(theme) ? theme : "Default");
            }

            return result;
        }
    }

init

 ThemeManager.Instance.Configure(config =>
 {
    config.ThemeDirectory = "~/Themes";
    config.DefaultTheme = "Default";
    config.ThemeResolver = new SessionThemeResolver();
 });

Save theme to sesion

 Session["Theme"] = "YourTheme";

aspnet.mvc.theming's People

Contributors

bugthesystem avatar mscarman173 avatar

Stargazers

Indeedornot avatar Namiq Aliyev avatar Dhiren Patel avatar Admir Pajalic avatar 百小僧 avatar Emel KIRIMLI avatar Evan avatar Kiarash Soleimanzadeh avatar Sirwan Afifi avatar Ramin ALirezaee avatar Mehdi Saeedifar avatar Robin avatar Salar Rabbal avatar Lee Kelleher avatar Le Minh Quang avatar Laurentiu LAZAR avatar  avatar yunus emre keskin avatar Mesut Talebi avatar  avatar  avatar

Watchers

Laurentiu LAZAR avatar  avatar  avatar Gökşah Taşyürek avatar Oğuzhan Demir avatar  avatar Robin avatar Fahad avatar JP Taljaard avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.