CMS Context

Figure 24-1 depicts the boundaries of a CMS Context.

Figure 24-1. CMS Context

graphics/24fig01.gif

From the CMS Context we can, given sufficient user rights, access and manipulate all channels, including the current channel (if there is one); access and manipulate all postings, including the current posting (if there is one) and the placeholder objects that they contain; access and manipulate both the template gallery and the resource gallery, including everything that they contain; and access and manipulate templates and their placeholder definitions. We can only access a few characteristics about the current user, and, unfortunately, we cannot manipulate the CMS security structure.

NOTE: We cover setting up user rights in detail in Chapter 17.


It is also possible to create temporary PlaceholderControls, but template files cannot be permanently altered through PAPI.

The two types of Context we explore in this chapter are CmsHttp Context and CmsApplicationContext.

Scratchpad

You are going to need a way to see the results of the code we write throughout Part VI. Sometimes it helps to simplify the environment so that you know everything that went into its creation. Most of what we do in these chapters will be the equivalent of using a scratchpad to do math problems. In the end, it isn't what is on the scratchpad that has any value; it is the principles that you learned from what you did on the scratchpad. Anything that is done of any consequence can be readily ported to your real project.

Steps for creating the Scratchpad posting used throughout Part VI: Create a new channel. (See Chapter 16 for help with creating channels.)

  1. Using Site Manager as a CMS administrator, create a new channel called Scratch. Just take all the defaults.

  2. In the Properties of the new Scratch channel, select the Publishing tab and remove all text, if any, from the Script URL text box in the Channel Rendering section.

Create a new VS.NET project. (See Chapter 10 for help with creating projects.)

  1. Using VS.NET, create a new C# project called http://localhost/vsScratchpad using the MCMS Web Application template.

  2. When prompted, authenticate as a CMS administrator.

Create a new template file. (See Chapter 12 for help with creating a template file.)

  1. Using the VS.NET Solution Explorer, add a New Item called ScratchpadTemplate.aspx using the MCMS Template File template.

  2. In the Properties of the new ScratchpadTemplate.aspx, change the pageLayout from GridLayout to FlowLayout.

  3. Drop the following Web Form controls onto the ScratchpadTemplate.aspx Design palette: TextBox, Label, ListBox, and Button.

  4. Use the Enter key after each control to place each control on its own line.

  5. Change the width of the TextBox, Label, and ListBox to 600px.

  6. Drop the DefaultConsole.ascx from the Console directory onto the ScratchpadTemplate.aspx Design palette after the Web Form Button control.

  7. Double-click the Web Form Button control to create the Button1_Click function in the code-behind window.

Create a new template definition. (Again, see Chapter 12 for help with creating a template definition.)

  1. Using the VS.NET MCMS Template Explorer, create a new template called ScratchpadTemplate.

  2. In the TemplateFile property of the new ScratchpadTemplate, enter the text "/vsScratchpad/ScratchpadTemplate.aspx" or select the ScratchpadTemplate.aspx file.

  3. Select Build Solution from the VS.NET Build menu.

Create a new posting based upon the new template in the new channel. (See Chapter 5 for help with creating a posting.)

  1. Using Internet Explorer, browse to the Scratch channel: http://localhost/Scratch.

  2. When prompted, authenticate as a CMS administrator. If you get the Homeport page instead of the channel Welcome page, you forgot to remove the Script URL in step 2 when creating the channel. You can do it now.

  3. Click the Switch to Edit Site link, click the Create a New Page link, click the Templates link under the Template Gallery column, and select the ScratchpadTemplate.

  4. Click the Save New Page link.

  5. In the resulting dialog, enter "Pad" into the Name text box and click the OK button.

  6. Click the Approve link and then close Internet Explorer.

Open Internet Explorer and browse to http://localhost/Scratch/Pad to see the Pad posting (Figure 24-2) we created. You may be required to authenticate.

Figure 24-2. Scratchpad in Internet Explorer

graphics/24fig02.gif

Now we can repeatedly enter code into the Button1_Click function of the underlying template file, refresh the browser, and see the results of that code in this posting. Sweet.




Microsoft Content Management Server 2002. A Complete Guide
Microsoft Content Management Server 2002: A Complete Guide
ISBN: 0321194446
EAN: 2147483647
Year: 2003
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net