четвер, 30 листопада 2017 р.

Asset library Video content type

Hi there!

If you have ever tried to upload a video to Asset Library you might have noticed its different behavior compared to Documents Library.

When you have uploaded the video you will find that the file itself is located inside additional "folder". This additional folder is actually a Document Set not a simple folder.
You set the name for this DocSet when you create Video item. But the video file will be saved with its original file name. So it is better to rename the file before uploading if you want nice URL.

One interesting thing is that when you try to open this Video item in Explorer, using menu action on the Library tab, Explorer will actually open "Additional Content" folder which is created inside the DocSet when you create the Video item.
Also when you put something to "Related" it will appear in this Additional Content folder not inside the Video DocSet.

To be honest I can't understand where does this magic happen.
If you open DocSet "home" page, which is AssetsLib/Forms/Video/videoplayerpage.aspx by default, you will find OfficeServer:DocumentSetContentsWebPart which is used to show content of the usual DocSet, but in case with Video content type it shows content inside Additional Content folder inside DocSet.

Also, if you look through browser's log, you might see some redirections. For example:

GET
.../TestAssetsLib/Test%20clip

HTTP 302 Redirect
Location: 
.../_layouts/15/DocSetHome.aspx?id=/TestAssetsLib/Test%20clip
&RootFolder=/TestAssetsLib/Test%20clip

GET
.../_layouts/15/DocSetHome.aspx?id=/TestAssetsLib/Test%20clip
&RootFolder=/TestAssetsLib/Test%20clip

HTTP 302 Found
Location: 
.../TestAssetsLib/Forms/Video/videoplayerpage.aspx?ID=4
&FolderCTID=0x0120D520A8080048096958098E9546A5AF9E5EF12F8411
&List=c4fdc911-1976-4016-84dc-d09c5e4b6dd5
&RootFolder=/TestAssetsLib/Test%20clip/Additional%20Content
&RecSrc=/TestAssetsLib/Test%20clip

GET
.../TestAssetsLib/Forms/Video/videoplayerpage.aspx?ID=4
&FolderCTID=0x0120D520A8080048096958098E9546A5AF9E5EF12F8411
&List=c4fdc911-1976-4016-84dc-d09c5e4b6dd5
&RootFolder=/TestAssetsLib/Test%20clip/Additional%20Content
&RecSrc=/TestAssetsLib/Test%20clip

HTTP 200 OK

So somewhere server sets RootFolder to Additional Content folder.

If you know something interesting about this, please comment! =)

пʼятниця, 24 листопада 2017 р.

Passing value to WebPart xsl

Sometimes you need to customize a SharePoint web part's appearance on a page, for example you want special look for ContentByQueryWebPart.To do that you can customize few xsl files (ContentQueryMain.xsl, ItemStyle.xsl). There are a plenty of articles about it over the Internet, so I won't talk about this in details.
But what if you want to use some value from the page in your xsl? Luckily there is a way to pass it using ParameterBindings element.

The code below allows you to pass different types of values to your xsl:
<WpNs0:ContentByQueryWebPart ...
WebPartAttributeName="WebPartAttributeValue" >
  ...
  <ParameterBindings>
    <ParameterBinding Name="StaticValue"
      DefaultValue="240px" />
    <ParameterBinding Name="WebPartAttribute"
      Location="WPProperty(WebPartAttributeName)" />
  </ParameterBindings>
</WpNs0:ContentByQueryWebPart>
To use this in your xsl define variables and use them:
<xsl:param name="StaticValue" />
<xsl:param name="WebPartAttribute" />
...
<h1 class="{$StaticValue}">
  <value-of select="$WebPartAttribute" />
</h1>
You can read more about ParameterBinding element here