We've added a CSWP to a site template, defined the query and added custom display templates with the Control and Item options. However, when we create new sites from the template, the new CSWP defaults to the standard "List" and "Picture..." Control and Item options. I have tried recreating the template but got the same each time. It seems odd that it takes part of the customisation. It also seems to default the Global nav to have unique settings, even though I've set the template to use the parent nav. Can anyone suggest a solution? Thanks Bill
1 Answer
I've managed to find the cause and solution to this problem:
The cause is identified in Chris O'Brien's blog:
http://www.sharepointnutsandbolts.com/2013/04/provisioning-content-search-web-part.html
as being due to the way the tilde character is treated in the template Ids: ~sitecollection
In the comments Ivan Neganov provides a fix, i.e. to replace the tilde with escape characters: ~sitecollection
As I'm not a programmer and don't have VS, I couldn't make use of the solution until I found this posting: http://www.fmtconsultants.com/2014/10/solution-to-sharepoint-2013-issue-content-search-web-part-does-not-retain-properties-when-creating-a-site-from-a-custom-template, written by Abdur Raheem, Senior SharePoint Consultant, FMT Consultants, which explains how to strip out the Elements.xml file from the Site Template solution file, update it, as per Ivan's suggestion and recreate the solution.
I had issues with the DDFgenerator and spaces and with activating the uploaded solution but finally got it working :)
After reading Chris' blog, I tried just swaping for the escape characters in the site that is used to create the template, via SharePoint Designer but this broke the display template. Its possible, however, that using this broken template might produce a working solution, one it is saved as a site template, which would provide a very simple solution. It can't be that easy but when I next have to make this work, I'll give it a try and post the results