The Web Author .NET application is constructed from many ingredients. The architecture is based on ASP.NET principles, so if you are familiar with ASP.NET, then you will be comfortable with the Web Author. The console itself is contained within a .NET user control, the controls within the console are .NET server controls, and the underlying code is contained within .NET classes (e.g., the WebAuthorContext). Web Author ControlsThere are a few different types of .NET server controls within the Web Author architecture (Figure 30-1): console controls, site mode container controls, action controls, and status controls. The fact that these controls are all .NET server controls offers great advantages in terms of class inheritance and development experience. Figure 30-1. Web Author .NET architectureConsole ControlsCMS ships with two console controls. These two server controls are the authoring console and the error console. The controls are used to encapsulate the .NET server controls used by the Web Author. When you open the WoodgroveNet DefaultConsole.ascx file in design mode, you can see these two controls. The authoring console appears when a CMS user clicks the Switch to Edit Mode link. The error console is displayed when the WebAuthorContext class encounters an error. To make things easy, the two controls are displayed within the same .NET user control. For example, when you add the WoodgroveNet default console or the BOTS Consulting console to a template, you are also adding the error control. Site Mode Container ControlsSite mode containers enable Web Author controls to act differently under different Web Author modes. There are three types of container controls: presentation mode containers, authoring mode containers, and error mode containers. For example, looking at the source for the DefaultConsole.ascx file, you can see container controls such as PresentationModeContainer and AuthoringModeContainer. These containers give the CMS developer an easy way to organize the Web Author action and status controls. If you created a new custom control, you could add your control to one of these containers and you would not have to worry about the control appearing in the wrong CMS mode. In other words, you do not have to write any code to determine whether your control appears in the WebAuthorContext Published mode or authoring mode. The mode containers support a number of different submodes, shown in Table 30-1.
Example: Displaying the Web Author ModeYou may be curious about these modes and when they come into play. Add this code to your DefaultConsole.ascx file to output the current Web Author mode. using Microsoft.ContentManagement.WebControls; <% WebAuthorContext webAuthor = new WebAuthorContext(); string mode = webAuthor.Mode.ToString(); Response.Write(mode); %> Action Controls and Status ControlsThese .NET server controls are the most obvious components within the Web Author console. Status controls are used to display information about CMS objects (such as the publication status of the current posting), and action controls allow CMS users to do things like create or edit the content on the Web site. Action controls and status controls render HTML inside server control tags. Rather than restricting the rendering of the controls, they provide an object model to retrieve rendering details. For example, the Text property is used to show the text within the anchor tags, and the Action Javascript property determines the JavaScript that runs when the link is clicked. The following are examples of Web Author action controls:
The following are examples of Web Author status controls:
Most of the Web Author action controls are contained within the container control for authoring. The only one that is visible in presentation mode is the link that allows a CMS author to switch to Unpublished mode. This is the Switch to Edit Site link that you see as a CMS user with authoring rights. The control has added logic that hides the link if the current user is the CMS guest account. WebAuthorContext ClassThe WebAuthorContext class is the heart of the Web Author application. CMS offers different rendering of pages based on different modes. It is the WebAuthorContext class that allows the Web Author to manage these different modes. For example, in Published mode, CMS placeholders render content, but in Unpublished mode it is usual that they allow authors to edit the content. It is the WebAuthorContext.Current method that allows the Web Author to detect the current mode. Take a look at the CMS help files for a complete breakdown of the WebAuthor Context class. This is the same class that handles the new PAPI event model. CMS developers can use the event model to perform custom actions based on changes to the CMS site for example, when new pages are created. But this is a topic for another chapter. |