Tuesday, August 30, 2011

Using the built in Overlay Media player in SharePoint

This is a simple and cool feature to add some impressing features to your site.

And it can be all done from a Content Editor Web Part if you like by using a <div> and the built in mediaplayer.js script shipping with SharePoint.

Here is an example on how it could be used:





Friday, August 26, 2011

Open Edit form directly from Content Query

Some background for why I wanted this. I had a content type for registration of different tasks, and for underlying reasons I needed to split it into different SharePoint Lists. I wanted an easy way for users to register some data for the "tasks". Anyway I thought about setting up a CQWP on the users "Dashboard" querying for all the tasks of the content type, and link it directly to an edit form created with InfoPath.

1.
Its actually pretty easy to do this, first you'll need a template set up in ContentQueryMain.xsl. Search for the OuterTemplate.GetSafeLink, and copy and paste it right below. Now all you'll need to do is ofc change the name of the template, I just named it OuterTemplate.GetEditLink:

<xsl:template name="OuterTemplate.GetEditLink">
 <xsl:param name="UrlColumnName">
	<xsl:if test="$UseCopyUtil = 'True'">
	 <xsl:value-of select="concat($RootSiteRef,'/_layouts/CopyUtil.aspx?Use=id&amp;Action=editform&amp;ItemId=',@ID,'&amp;ListId=',@ListId,'&amp;WebId=',@WebId,'&amp;SiteId=',$SiteId,'&amp;Source=',$Source)">
	 </xsl:value-of>
	</xsl:if>
	<xsl:if test="$UseCopyUtil != 'True'">
	<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
	<xsl:with-param name="UrlColumnName" select="$UrlColumnName">
	</xsl:with-param>
	</xsl:call-template>
	</xsl:if>
 </xsl:param>
</xsl:template>

The only change made to template other than the name is the Action=, changed to editform, that's it.

2.
Now for using it in a CQWP you'll need to set up an ItemStyle to use it. Make a variable to use the new template.

<xsl:variable name="SafeLinkEditUrl">
   <xsl:call-template name="OuterTemplate.GetEditLink">
      <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
   </xsl:call-template>
</xsl:variable>

3.
And then its set to use with xsl:value-of.

<a href="" title="{@LinkToolTip}" 
      onmouseover="javascript:this.style.cursor='hand';"
      onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('{$SafeLinkEditUrl}');return false;">
          <xsl:value-of select="$DisplayTitle"/>
</a>