Today I created a display template within SharePoint 2013 site showing document that are checked out to me. All easy until I created a mix of publishing and team sites.
Within my display template I was using the following line to create a check in button next to my document name:
[code lang=text]
<button id=”tr-checkin” style=”float: right;” type=”button”>Check in</button>
[/code]
The Url in ctx.CurrentItem.Path for my documents in team site would look like this:
http:/ /myspdev/subsite/team/Shared Documents/Doc1.docx
All great!
But then when I added a checked out document to a team site. I found that my url for the document was set to the display form rather than the document url:
http:/ /myspdev/subsite/Shared%20Documents/Forms/DispForm.aspx?ID=1
So I updated my display template to point the use to the edit form using the link to the display form. At least there is a checkin button there:
<!--#_ if (path.indexOf("ID=") !== -1) { #-->
<a id="tr-checkin" style="float: right;" href="#= ctx.CurrentItem.Path =#">Check in</a>
<!--# } else { #-- >
<button id="tr-checkin" style="float: right;" type="button">Check in</button>
<!--# } _#-->
So it looks like there are more differences between publishing libraries and non publishing libraries than expected. I had a look through other crawled properties within the search configuration, but couldn’t find anything that points to the document within my team sites.
Not wanting to be beaten that easily I created some more sub sites and then I found that some of my team sites were returning the right url. So could the issue be related to something else?
In the above screenshot the readme file is a .md file. So it looks like Markdown files are not handled properly within the SharePoint search engine.
My guess is that SharePoint is being “helpful” for file extensions it can’t open in the browser. But in your case, it’s not so helpful.
M.
Hi Marc,
Indeed. I’m not sure though why this depends on the file format. So far I’ve seen the issue with Markdown. At least most common office file formats don’t seem to cause any problems.