Friday, April 15, 2016

Sitecore using a custom template for PDF and other media items

In cases where you index PDF content in Sitecore, it's a good idea to set a flag on the template which allows the content authors to exclude the item from search results. Instead of editing the system templates (both unversioned and versioned), it's possible to use your own. Simply:
  1. Create a new template which inherits from the base Sitecore media template 
  2. Add the custom fields or reference another base template which relates to search
  3. Open up the web.config (or sitecore.config) file and look for the mediaLibrary mediaTypes node
  4. Find the mediaType node for the template you are replacing
  5. Update it to use your new template
<mediaType name="PDF file" extensions="pdf">
  <mimeType>application/pdf</mimeType>
  <forceDownload>true</forceDownload>
  <sharedTemplate>Path/MyPDF</sharedTemplate>
  <versionedTemplate>Path/MyPDF</versionedTemplate>
</mediaType>

Simple, now there is no need to hack any of the Sitecore system templates

No comments:

Post a Comment