Example 6 - Adding a title link to an item in a document list

To add a title link in a document list, do the following:

  1. In the Program Files\Common Files\Microsoft Shared\web server extensions\50\Templates\1033\xml directory, open ONET.XML.

  2. Find the BaseTypes section and, within this section, find the BaseType element where the Type attribute is set to 1.

  3. In the Fields section within the MetaData element for this base type, add the following entry:

    <Field ReadOnly="TRUE" Type="Computed" Name="LinkedToTitle"
      DisplayName="Document Title" DisplayNameSrcField="Title"
      AuthoringInfo="(linked to document)">
        <FieldRef Name="Title"/>
        <FieldRef Name="FileRef"/>
        <HTML><![CDATA[<A HREF="]]></HTML>
        <HttpHost URLEncodeAsURL="TRUE"/>
        <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
            <Column Name="Title"/>
          <Case Value="">
            <UrlBaseName HTMLEncode="TRUE">
              <LookupColumn Name="FileRef"/>
            <Column Name="Title" HTMLEncode="TRUE"/>
  4. Save ONET.XML.

  5. Create a new document library.

    The document library has an extra field, Document Title (linked to document), that may be added to views of that document library. It is a computed field that consists of a link to the document. The text of this link is the title of the document (if it has any title at all); otherwise, it is the file name. This is accomplished via the Switch statement.

See Also

Introduction — What Is CAML?

Location of CAML