Creating document library template files can be extremely useful if you are going to have multiple libraries which use the same unique settings. The purpose of the template is to take an exact replica of the settings you have chosen in the list/library you’re creating a template from. However, a recent requirement I had for a template resulted in the discovery of a setting which is not replicated in the template – Opening Documents in the browser.
The Open Documents in the browser setting is set in each Document Library based on the Site Collection Feature ‘Open Documents in Client Applications by Default’.
If this feature is not activated, documents will open in the Web App. If this site collection feature is activated then the setting is changed to the ‘Open in the client application’ setting. The status of this feature overrides any templates created from a Document library. So if the above feature is deactivated, the setting is set to ‘Use the server default’ for all Document Libraries and even if you change the setting and save a template, the setting is defaulted back to the setting based on the Site Collection Feature status.
Looking at this in a little more detail when a site template file is created, an XML file is generated and the attribute for setting the ‘Open Documents in the Browser’ is absent from the XML. So in order to get around this issue we need to get into the XML of the Library template and make some changes.
If you need information on the latest version of SharePoint we also have an eBook on SharePoint 2019.
In order to make any changes to a library template file follow the steps below. In this example we will be changing this template to include the ‘Open Documents in the Browser’ attribute so we can set this setting to whatever we need it to be. This process can be followed to change any settings in a library template.
- Download the template file from SharePoint. This is found in the List Templates area (see below). Select the template file and select ‘download a copy’ from the Files Ribbon.
Navigate to the List Templates location by adding this to the end of your root site URL:
- Locate the template file in the location you downloaded it
- Right click on the .stp file and select ‘Rename’. Change the extension from .stp to .cab
- A pop up will appear asking if you’re sure you want to change it. Select Yes.
- .You now have a file with the extension .cab and the icon will have changed to a cabinet.
- Double click on the cabinet file and then double click on the manifest.xml file within it.
- You will be asked to extract the file. Select a short path (for example, C:/Template) and extract.
- Navigate to the location of your extracted manifest.xml file and then open in an editor of your choice. In this example Notepad++ is being used.
- Search within your editor for the following attribute: ‘DefaultItemOpenUseListSetting’
- If you find this attribute, its value will be 1. Change this to ‘False’ of if the attribute doesn’t exist, add it in and assign its value to false.
- You then need to add a new attribute – ‘DefaultItemOpen’ and set its value to ‘PreferClient’.
- Those are all the changes required. Now you need to create a cabinet file containing this xml file and then change it back to a .stp file.
- Firstly, be sure to save your changes to the xml file
- Create a new notepad file and paste in the code below, replacing the red text for your own paths and filenames.
.OPTION EXPLICIT ; Will Generate errors for mistakes
.set DiskDirectoryTemplate=CDROM ; All cabinets go into a folder
.Set CompressionType=MSZIP ;** All files are compressed to cabinet files
; Create destination Folder of your choice
.Set DiskDirectory1=C: cabinets
; File name for the new cab file
; Files to be added are listed below
Save the notepad file with the following name and extension. Set the ‘Save as type’ to ‘All Files’
Save As: a.ddf
- Open the Command Prompt and enter the following:
makecab /f C:yourlocationa.ddf
- Hit Enter and you should see the results below:
- If you’ve followed the above steps correctly your Cabinet directory and Cabinet file will have been created.
- Navigate to your newly created Cabinet file and rename the extension from (.cab) to (.stp).
- You have now successfully amended the settings of your template file and created a new template file which you can upload to SharePoint and use in your site.
For more help have a look at our local Edinburgh & Aberdeen SharePoint page.