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”
AutoEventWireup=“true”
 %>
<asp:Content ContentPlaceHolderID=“ContentPlaceHolderDefault” runat=“server”>
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”[]>
    <html xmlns=“http://www.w3.org/1999/xhtml”>
        <head id=“head” runat=“server”>
            <title>Email Output Template</title>
        </head>
        <body>
            <umbraco:Item field=“siteName”
              insertTextBefore=“&lt;meta property=‘og:site_name’ content=’”
              insertTextAfter=“‘/&gt;” recursive=“true” runat=“server”>
            </umbraco:Item>
        </body>
    </html>
</asp:content>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.103.5