The goal of this post is to present detailed, step-by-step instructions on how
to install, modify and maintain themes (skins) in MonoX-based projects. As you probably know, a theme is a collection of property settings and resources that allow you to define the look of pages and controls, and then apply the look consistently across pages in a Web application. Designers of MonoX-based applications will spend most of their times working with themes, and some of our users do not go beyond making design changes to their applications. Therefore, it is very important to grasp the basic concepts and follow the techniques described below in order to develop a standardized and maintainable front ends for your applications.
1. MonoX themes
With the new MonoX 4.9 release, we have made some changes related to theming functionality. Some of the techniques described here will also be useful in older versions, but we will focus on the current version. New theme that comes with MonoX 4.9 also contains a skin chooser which allows you to easily modify your themes.
One of the major changes in the new "Modern" theme is switching functionality based on SASS and Zurb Foundation framework. SASS is a meta-language on top of CSS that’s used to describe the style of a document cleanly and structurally, with more power than flat CSS allows. SASS both provides a simpler, more elegant syntax for CSS and implements various features that are useful for creating manageable stylesheets, so basically SASS is an advanced version of the plain old CSS. Installation and usge of SASS is explained in one of our previous posts witch you can find here, and is also very well explained on the Zurb Foundaton website here.
Zurb Foundation is a framework built on SASS (in our case), which contains predefined styles for Grid, Typo, Buttons, Navigation, Forms, UI Elements and other components of website layout. It is extremely modular and allows you to use just the components you need, and modify them in an easy way. More about Using Zurb Foundation can be found here.
In addition to SASS and Zurb Foundation, we also use Compass, which is a bundle of SASS functions that allows us to work faster and easier. More about Compass can be found here.
These new technologies together make MonoX themes easier to use and to modify. Our recommendation is to explore both SASS and Zurb Foundation documentation before proceeding to custom styling tasks on MonoX.
1.2. Basic theme structure
MonoX theme is a bundle of files and folders that builds and style your MonoX application. New theme that comes with MonoX 4.9 was redesigned from the ground up. See the picture below for a comparison of the new and old theme structure.
1.2.1. Design Section
220.127.116.11. Including external files
1.2.2. HTML implementation section
HTML implementation section holds a number of folders with supporting HTML markup and additional resources related to the specific theme.
App_Templates folder contain web part templates - snippets of HTML that holds the layout for one data item in the repetitive web parts and controls. They are bound to a specific theme and placed into the folder with a theme name.
Membership folder holds pages with functionality related to user membership (registering, password and email recovery, ...).
MonoX folder contains all general elements that are used accross your application. It contains master pages, page templates and content pages, controls and web parts. Its usage is explained later in this post.
This section holds a few "standalone" pages - Default, Login and Blog. Default.aspx is a default entry point/home page for your application.
1.3. Installation of the new MonoX theme
Fresh installation of MonoX comes with a Default theme installed. If you wish to install a new theme, you will have to download it from our website. Theme installation package is basically a .zip file which can be extracted into the root folder of your MonoX installation.
1.3.1. Design section
By extracting theme in your root folder, a subfolder with the name of new theme will be created in the App_Themes folder containing all supporting resources.
1.3.2. HTML installation section
Same as before, after the extraction of the new theme is finished, the App_Templates folder will contain a subfolder with the name of the new theme.
Files in the MonoX and Membership folders, as well as standalone pages (Default, Login and Blog) will be overwritten by the new theme files.
1.3.3. Switching to new theme
After you have installed the new theme, just switch to it using the main web.config file as shown below:
2. building new pages in Monox
2.1. Building blocks of a MonoX page
Every MonoX project contains a set of pages (master pages and page templates), controls, web parts and web part templates that together describe its UI. The main organizational blocks used to build a page structure are content placeholders and web part zones - more details about page structure, content zones and placeholders can be found in MonoX documentation here. Here are step-by-step instructions for building MonoX pages.
2.1.1. Building pages
Image 4. CP – Content placeholder, WPZ – Web part zone
ASP.NET content placeholder is a basic structural block used to organize the page nesting hierarchy. Content placeholders mark the regions where various content controls - or child content placeholders - will be placed.
Web part zone is a control that allows you to include dynamic content on the page. It marks the region where you can drag and drop web parts in the administrative mode. Zones also give you the run-time control over the web part parameter and various other settings.
2.1.2. Nesteing pages in MonoX
Main Master Page – contains basic HTML tags such as <html>, <head>, <body>, page title, basic scripts and CSS references etc. It also contains a Content placeholder which is used to hold nested nested master pages and their respective content.
Master Page – inherits Main Master Page and nests content into the content placeholder of the Main Master Page. Here you can build a layout grid, insert more placeholders (which you can leave empty if not needed), or you can fill it with the content common to all pages, such as header and footer. Naturally, you can have more than one master page to implement more layouts.
Page Template – inherits Master Page, and it includes other content elements. You can implement an unlimited number of page templates this way.
2.1.3. Building page templates
Grey areas on Image 5. marked as content are arbitrary MonoX elements that are used to compose a page:
Web Part Zone – zone where you can add Web parts statically (via code) or dynamically (via administrative mode). Web parts can also live outside Web Part Zones, but their properties cannot be edited interactively. In this mode, they also cannot be moved around via the drag and drop operation.
Control – a control that implements arbitrary functionality
Web Part – basic functional building blocks of a MonoX application
Web Part Template – HTML snippets that hold the layout for one data item in the repetitive Web part sections
Custom Content – any other custom content.
Bellow you can see examples of page templates:
As you can see on Image 7. you can combine Web Part Zones and other content in any way you want.
Code example of a page that contains a control and a WebPartZone:
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>
<%@ Import Namespace="MonoSoftware.MonoX.Resources" %>
<%@ Register TagPrefix="MonoX" TagName="MyWebPart" Src="/MonoX/ModuleGallery/MyWebPart.ascx" %>
<%@ Register TagPrefix="MonoX" TagName="MyControl" Src="/MonoX/Controls/MyContorlascx" %>
<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX" TagPrefix="portal" %>
As you can see, we just have to reference the right master page and put the content inside the content placeholder using the arrangement that is suitable for our purposes.
3. Handling themes In NEW MonoX applications
3.1. Design section
As we mentioned before, all styling in the new theme is handled through SASS. In theory, you could just start editing the CSS file as before, but than you would loose all the benefits of the SASS approach - note that SASS would overwrite all the changes you made on every compile. Therefore, from now on we will use only the new, SASS-based approach.
In Image 8. you can see a sample of the SASS folder content. Default.scss contains numerous include functions that reference other SASS files. By doing this, we will end up with a single CSS file after SASS files are compiled. "Settings" files hold variables that are used throughout the project, and allow quick and easy property changes.
New theme includes various skinning options - changing color, font, font size, etc. Skin files are basically groups of variables which control the basic parameter values. You can change skins in Default.scss by uncommenting and commenting skin include functions.
In Image 9. you can see a part of the skin file and its variables.
Image 10. shows how to include a theme in Default.scss file.
You can use our predefined skins, modify them or build your own skins. In case you want to modifying styling to a greater extent, you can go through other SASS files and change code there. As you can see in Image 8., beside some global styling files, every SASS file is responsible for a specific MonoX section.
3.2. HTML Implementation section
The best practice when using pre-existing MonoX themes is to keep files in this section unchanged as much as possible.
Note: New theme installation will overwrite all files in MonoX and Membership folder and also Default, Blog and Login pages.
So, as long as you perform all customizations by editing SASS(CSS) and Web part templates, and not doing any custom work on pages, controls, web parts and Default, Blog and Login.aspx, your application will be able to include new themes without any problems.
If you have to do custom work in those files, you should read the instructions below.
4. Handling themes in existing MonoX applications
If you have modified a default MonoX installation and you want to install a new theme, the installation process will be slightly different than previously explained.
4.1. Design section
New theme installation will create a new folder in App_Themes, nothing gets overwritten, so all of your custom work will remain stored in the old theme folder.
4.2. HTML Implementation section
App_Templates - new theme installation will create a new folder here, same as described in the Design section, so all of your custom work will remain stored in the old theme folder.
Problem comes with MonoX and Membership folder, and Default, Blog and Login pages.
Note: In order to keep your custom work in the HTML implementation section you should create a new folder in the root of your application named by your theme name. Copy all pages, controls and web parts from MonoX and Membership folders to it before you start installing a new theme.
Additionally, you should back up your Default, Blog and Login.aspx if any custom work was done on them.
Image 11. shows how your folders should look like if you want your existing work to remain unaffected by the new installation.
Also, if you modified Default, Blog and Login.aspx prior to the new theme installation, you should restore them from the backup after the installation is complete and set up HTML structure and CSS classes to fit new theme rules.
Since the new theme will use new Web part templates from App_Templates, you should also check if any changes need to be done there.
5. Building a custom theme
Building a new theme from scratch would involve the next few steps:
You should organize the resources withing the folders with self-describing names, as displayed below.
You should follow the guidelines from the existing MonoX themes. You can start by creating global styles and a global grid, and then go through individual sections and style them one by one, working simultaneously on SASS and HTML. There is a lot of styling and layout related stuff in the Zurb Foundation that can be used as is.
5.2. Managing HTML Implementation files
Now you are ready to start creating all other custom pages (explained in 2.1.1.) and modify individual page/web part templates as needed.
I hope that the material from this post will help you in styling your new or existing MonoX-based projects. Please free to contact us with all questions or comments.