USING THE UMBRACO TAGS

Chapter 4 introduced you to the special tags that Umbraco utilizes for outputting content to templates. These tags are referenced in templates as .NET custom tags and take on the format you see in the following code:

<umbraco:item field=“” someOtherAttribute=“” runat=“server” …/>

If you have ever registered a user control (.ascx) in a .NET project, this code should look strikingly familiar to you. In its most basic form, the tag takes the field attribute and returns a value for the specified field name, assuming it exists in the context of the page that the template is rendering. For a summary of the various available attributes and what they do, see Table 9-1.

TABLE 9-1: Umbraco Tag Attributes

image

image

In many cases you can use a combination of the preceding attributes. For example, if you are trying to insert an HTML tag with attribute values (like a meta tag), you can accomplish this by using the insertBefore and insertAfter attributes simultaneously. See Listing 9-1 for an example. To see how you can access these attributes via the Umbraco backoffice UI, see Chapter 4.

LISTING 9-1: OutputMetaTag.master

image
<%@ Master Language=“C#” MasterPageFile=“∼/umbraco/masterpages/default.master” ...

Get Umbraco User's Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.