Adding Custom Properties

Another element of a TGI is the custom property definitions. Custom properties allow a developer to assign additional metadata to a template, the values of which can be assigned by the content contributor (or the developer, programmatically). These custom properties can then be used in a number of ways, including creating HTML META tags, determining what content to summarize on a posting, searching for specific postings, and determining what content to display to a subscriber. Your design will largely determine whether you need custom properties and how to use them. In BOTS Consulting's case, custom properties are used in the case studies section to allow subscribers to see case studies of a particular type.

NOTE: Although custom properties are a terrific way of providing a flexible tagging structure for content in CMS, searching by them is an expensive transaction. Overuse of custom property searches can seriously impact the performance of your CMS site. Good uses for custom properties might be certain metadata about the page, such as key words or the GUID of a related posting; you would retrieve the value at the posting level and then search on the GUID, which is a very efficient search.

As we mentioned earlier, custom properties allow developers to create custom attributes for postings. In the same way that placeholder definitions define what each placeholder will accept, custom properties define what additional attributes a posting can possess and, in some cases, what values can be applied to those properties. When the content contributors create new postings based on the template, the posting will possess the properties defined in the TGI, and the content contributor assigns the values.

When you create your TGI, you have the option of creating a custom property collection. This collection will hold the custom properties to which you want the content contributor or some automated process to assign values. When you create your properties, you have the choice of two types: selection and text. Each type defines the behavior the content contributor will see when they create a posting based on this template. If you look at Figures 10-14 and 10-15, you can see the ellipsis that you click to call up the Custom Property Definition Collection Editor and the interface itself (similar to the Placeholder Definition Collection Editor).

Figure 10-14. You click the ellipsis to see the custom property definition interface.


Figure 10-15. This is the interface you use to create the custom properties in your template.


The selection custom property allows the developer to create a property and then provide a fixed number of "allowed" values. Essentially, this creates a drop-down list of values that a content contributor can set when they create a new page. The advantage to a selection custom property is the limited number of values the property can hold. This is especially useful if you need to search for a posting using a custom property, since you have to search for an exact value match (there's no facility to search "like" with a custom property), or you need to exactly match a property and value pair. The downside to selection custom properties is that the values cannot be updated programmatically; you must change the allowed values through the VS.NET interface. Keep in mind that you must supply a "default" value for the property. By default, CMS chooses the first property you enter.

In Figure 10-16 you can see how the selection custom property appears to the content contributor in the Page Properties dialog. In this case, the Case Study Detail template has one custom property to designate the industry with which the case study is associated. In the BOTS' site, there's only one channel for all case studies, regardless of what practice contributed the study. However, the business users wanted a way to tag each case study so they could visually segment the case studies when being viewed by potential customers.

Figure 10-16. The Page Properties dialog is where content contributors can set the value of custom properties.


The text custom property allows the business user to fill in a free-form value. Text custom properties are useful when there is no specific set of values a property can have. They are especially useful when developers are assigning values to properties programmatically.

With the Generic TGI you created earlier, let's add a custom property to the custom property collection. As shown in Figure 10-14, click the ellipsis. Once you've clicked the ellipsis and you see the Custom Property Definition Collection Editor, click the down arrow next to the Add button (simply clicking the Add button will, by default, create a text custom property). For this example, let's add a selection custom property. After you've completed this step, you should see something like Figure 10-17.

Figure 10-17. The Custom Property Definition Collection Editor with the new custom property


You'll notice that CMS automatically gives the new custom property a name (as it did with the template and template gallery). To change the custom property name, simply click the Name property and change it. In this example, we'll call our new custom property "sample."

Because this is a selection custom property, CMS automatically creates a new item in the collection of values. Similarly to adding a new custom property to the TGI, you also can create new values in the allowed values collection. The allowed values collection is the list of values that will fill the property's drop-down list in the Page Properties dialog box. For this example, we'll add two values: Value1 and Value2 (we're not terribly creative). To add the values, click the Allowed Values property and click the ellipsis to see the Allowed Values Collection Editor (are you seeing a pattern yet?).

You'll notice that there is already one value in the collection. As mentioned earlier, because you selected a selection custom property, CMS automatically fills the allowed values collection with one member. Since one value already exists, simply click the value's property field to the right and change the value to "Value1." To add a new value, simply click the Add button and change the value to "Value2."

Figure 10-18 shows what you should be seeing in VS.NET once you've completed the preceding steps.

Figure 10-18. The allowed values you've just added


Microsoft Content Management Server 2002. A Complete Guide
Microsoft Content Management Server 2002: A Complete Guide
ISBN: 0321194446
EAN: 2147483647
Year: 2003
Pages: 298 © 2008-2017.
If you may any questions please contact us: