Home > Articles > Programming > ASP .NET

  • Print
  • + Share This
This chapter is from the book

Creating Templates

Authors use templates to create new web pages. Templates consist of page elements such as text and graphics along with placeholders that are used to capture input from the authors. For instance, a press release template would have placeholders for the date, title, text, and contact information. The same template would be used for all press releases, so updating the template would update the appearance of all press release pages. One way to define a new template is to right-click the template gallery in MCMS Template Explorer, and select New Template. Another way is to create the template in Visual Studio. You can rename a template you have just created. In either case, you use Visual Studio.NET to edit templates.

In MCMS 2002, templates are stored in ASP.NET files. They are checked in and out of the template library by the developer. This functionality is important to coordinate the efforts of multiple developers working on the portal. All developers share a common MCMS repository, and they check out templates as they need to access them.

Placeholders are ASP.NET server controls. This tight integration with .NET gives developers close control over the behavior of the templates and the resulting web pages. It also means that template developers need to learn and master .NET programming. These skills carry over into other portal products. For instance, SharePoint Portal Server now uses the same .NET approach to creating web parts.

The standard placeholders that ship with MCMS are:

  • HTML placeholder. Probably the most common placeholder; accepts HTML strings including text, formatting, and hyperlink tags.

  • XML placeholder. Designed for data formatted as XML.

  • Attachment placeholder. Allows user to insert a file as an attachment; displays resulting link to attachment.

  • Image placeholder. Stores image file such as JPEG.

  • Office Attachment placeholder. Contains Office file as an attachment.

  • Office HTML placeholder. Stores HTML generated by an Office product such as Microsoft Word.

You can also create your own new placeholder definitions with the Custom Property Definition Collection Editor shown in Figure 9.9. You can change the properties of these placeholders or even create your own custom properties. The example in the figure shows a custom property called Roles. This property determines whether the page is visible to public users (anonymous users) or whether it requires authentication to get access to it. The value stored in this property is editable for page authors on the Page Properties page. Be careful about proliferating the placeholder definitions and check to see whether an appropriate placeholder already exists before you create your own. There is no reason to needlessly complicate maintenance of your templates by reinventing the placeholder.

09fig09.jpgFigure 9.9. Placeholder Definition Collection Editor

MCMS offers quite a range of template design functionality and extensibility. A prerequisite for tapping this power is familiarity with Visual Studio .NET. You can create templates that use nearly anything you could build in a custom .NET web page.

  • + Share This
  • 🔖 Save To Your Account