Export (0) Print
Expand All

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

SharePoint Team Services 1.1

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)">
      <FieldRefs>
        <FieldRef Name="Title"/>
        <FieldRef Name="FileRef"/>
      </FieldRefs>
      <DisplayPattern>
        <HTML><![CDATA[<A HREF="]]></HTML>
        <HttpHost URLEncodeAsURL="TRUE"/>
        <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
        <HTML><![CDATA[">]]></HTML>
        <Switch>
          <Expr>
            <Column Name="Title"/>
          </Expr>
          <Case Value="">
            <UrlBaseName HTMLEncode="TRUE">
              <LookupColumn Name="FileRef"/>
            </UrlBaseName>
          </Case>
          <Default>
            <Column Name="Title" HTMLEncode="TRUE"/>
          </Default>
        </Switch>
        <HTML><![CDATA[</A>]]></HTML>
      </DisplayPattern>
    </Field>
  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


Show:
© 2015 Microsoft