Showing posts with label content type. Show all posts
Showing posts with label content type. Show all posts

Wednesday, July 25, 2012

PowerShell script to add "Link to a Document" content type to all document libraries


$linkct = "Link to a Document"
$docct = "Document"
Get-SPSite -Limit all | Get-SPWeb -Limit all | ForEach-Object {
    
    $doclibtype =[Microsoft.SharePoint.SPBaseType]::DocumentLibrary
    $doclibs = $_.GetListsOfType($doclibtype)
    
    foreach ($doclib in $doclibs) 
    {
$newdoclib = $_.Lists[$doclib.ID]
    if ($newdoclib.AllowContentTypes)
          {
            $newdoclib.ContentTypesEnabled = $true
           $newdoclib.Update()
    
              #Add site content types to the list
      if (($newdoclib.ContentTypes[$linkct] -eq $null) -and
               ($newdoclib.ContentTypes[$docct] -ne $null))
      {
               $ctToAdd = $_.Site.RootWeb.ContentTypes[$linkct]
               $ct = $newdoclib.ContentTypes.Add($ctToAdd)
               "Content type " + $ct.Name + " added to list " + $newdoclib.Title
               $newdoclib.Update()
            }
         }
     }
}

Monday, August 16, 2010

Configuration to use Content Type in search scope and to display the Content Type in core results web part

1. In Central Admin click on “Manage Service Applications” and select the Search service application
2. Select “Manage” from the ribbon control
Steps 3 and 4 are required if you want to display the content type data in the core results web part
3. Select “Metadata properties” from the left navigation and add a “New managed Property”
4. Give the new property a name, add crawled property mapping to Basic:5(Text) and ows_ContentType(Text), check “Allow this property to be used in scopes” and “Add managed property to custom results set retrieved on each query” check boxes. Click ok when done.

5. Select “Scopes” from the left navigation and select “New scope” to add a new scope for the content type.
Note: If you are using the inbuilt content type managed property then you have to edit the property and check “Allow this property to be used in scopes” check box.
6. After creating the new scope you should add a rule by clicking “New Rule” link.
7. In the new rule screen, check the “Property Query” for the “Scope Rule Type”
8. Select “ContentType” from the “Add Property Restriction” drop down if using the inbuilt Content type managed property if not select the managed property that you added in steps 3 and 4
9. Type in the content type name in the “=” text box below the “Add Property Restriction” drop down

10. Now drop a Core results web part to a page and set the scope to the one created in step 5
11. Add to the “Fetched Properties” under display properties of the core results web part
12. To display the raw XML that is generated, set the XSL editor property of the web part to