Embedding and Sharing Video in SharePoint

Introduction

The solution described here allows to embed video hosted on YouTube into SharePoint. The same approach may be applied for embedding video from another video hosting sites, for example from Vimeo.

The main idea here to store embedded video properties and not the embedded code itself.
For storing embedded video properties we will use Custom  List, see implementation section for description. Page for Video Links list (default view with embedded player)  is shown below

Usage

In order to embed a video into SharePoint:

  • On YouTube site click the Share button located under the video.
  • Click the Embed button.
  • Copy at least src attribute value provided in the expanded box (see table 1 for supported attributes).

  • Create new Video Link item  and paste attribute values for embedded code into Video Links item. Save it.

Table 1. Mapping between embedded code iframe attributes and Video Link item

Attribute name Video Links field name
src URL
width Video Width
height Video Height
allowfullscreen Allow Fullscreen
frameborder Frame Border

Video Links implementation

As was mentioned earlier only properties for embedded video code are stored and not the embedded code itself. For storing embedded video code properties is used Custom List that extends OOB Links List (TemplateType = 103)

For embedded video properties we create Video Link Content Type that inherits from Link CT (0x0105)

where we define the following fields

Pay attention, for rendering YouTube player Computed Field EmbeddedVideoOnForm is intended.
For rendering of a field on a List View the following XSLT style sheet is used

And finally, we create List Definition Video Links from Content Type Video Link. List schema and Template files for Video Links including whole project  may be found on GitHub.

References

  • Video Links project on GitHub
  • How to embed Vimeo player see here
  • How to embed YouTube player  see here
  • How to customize the rendering of a field in List View see here
Advertisements

Rendering Content Query Web Part results in Table Layout

It is known that OOB Content Query Web Part (CQWP)  renders results using Lists for arranging items as shown below

In ASP.NET WebForms for Web Control DataList there is a possibility to specify layout rendering mode using property RepeatLayout, what if the similar functionality would be available in CQWP?

So, our  goal to extend CQWP, i.e. in addition to List Layout rendering mode, lets implement functionality for rendering Content Query Web Part results in Plain Old Table Layout.
In this approach, we would like to achieve the following options:

  • Possibility to easily arrange results in columns
  • Specify items direction (horizontal or vertical)

Solution Structure

Content Query Web Part Class

Tool Part Class Implementation with the ability to specify Table Layout properties

Web Part manifest file

Pay attention that we provide custom XSLT for processing of the CQWP, for more details see How to: Customize XSL for the SharePoint Content By Query Web Part.

Main XSLT style sheet for rendering results in Table Layout

Results

Below is shown Web Part configured  to display results in 4 columns and horizontal mode layout

CBQTableLayoutHorizontal2

Visualizing organizational structure in SharePoint with Google Chart Tools

Sometimes in SharePoint we need to visualize hierarchical  data as organizational chart. Prerequisites: not to use  Flash or Silverlight technologies here.

So, in our scenario for storage of organization structure will be used SharePoint List based on Custom List , for rendering engine  Google Chart Tools.

Implementation

First, let’s take a look at list’s schema for storing organizational structure

Name Type Description
ParentOrgElement Lookup Used for parent/child relationship
OrgDescription Note Display text for chart box
OrgAdditionalProperties Note Visual behavior for chart box

From Google Charts library we’ll use Organizational Chart package only.

1. Google Charts Tools loading and package initialization

2. Fetch data using SharePoint Web Service from list that contains organizational structure

3. Bind data source and draw chart

Usage

Result page with Org Structure rendered as Chart in List View

 

Designing and deployment of Context Data in Nintex Workflow

Context Data in Nintex Workflow represent values specific to the workflow, the context of the item and the current task within the workflow. As an example below are some of them

Initiator: The username (domain\username) who caused the item to be entered into the workflow

Item URL: The URL of the item in workflow

The complete list of Contex Data items and how to manage it is described  in Nintex Workflow User Manual.

Designing custom Context Data usually include the implementation of specific handler(class). In Nintex Workflow API  for this purposes exist class ContextDataItemBase, from which all Context Data items usually inherits.

The implementation of Context Data for returning approvers comments in XML format is presented below

Below is shown page for managing Context Data with custom Context Data added  and Insert Reference dialog that demonstrates the usage of custom Context Data when designing workflow   

Now our goal to automate the deployment of Context Data. For example, it is possible to create Data Context item during feature activation. For this task we’ll use method of class CustomCommonDataCollection (in namespace:Nintex.Workflow) from Nintex Workflow API:

Adding Context Data item  in Nintex Workflow Management (shown below)

is equivalent to calling

You could grab the source code for the project that demonstrates how to provision Context Data here.

Automating deployment of reusable workflows in Nintex Workflow 2010

One of the options for creating workflows in Nintex Workflow 2010 (NW2010 for short) is to associate workflows  with Content Types.This category of workflows is known as Reusable workflows.

As stated in Nintex Workflow 2010 User Manual

A resusable workflow template allows the workflow to be used on a content type, list or library through the
default SharePoint Workflow settings option.
Reusable workflow templates can be created for use within a single site or an entire site collection

In our case we are only interested in reusable workflows for content types.

Let’s disscuss the scenario when we need to automate the deployment of reusable workflow. It may take place for example, when there are several environments. The approach discussed here allows to deploy workflows during feature activation.

NW2010 API contains publishing infrastucture (Nintex.Workflow.Publishing namespace) that allow to programatically publish workflow templates.
Class Publish contains  method

that allows to associate workflow using ContentTypeId parameter.

The method below demonstrate how to deploy reusable workflow file by passing it file name, contenttype name and workflow name(NWFMappingEntry parameter)  using Nintex API PublishAWorkflow method.

Project that demonstrates how to deploy Nintex reusable workflows may be found here

Integrating YetAnotherForum with SharePoint

Hi

Recently i was involved in creating forum for SharePoint 2010.

Our goals were:

  • Using existing OSS forum application, in our case we’ve chosen YetAnotherForum ver. 1.9.4 (YAF for short)
  • Installation & configuration from SharePoint (WSP)

Below is brief description of solution

1)Copying forum files.
First of all our solution copy YAF files into SharePoint layouts directory structure during installation.
Note: There is no need to create separate IIS Web Site or even Application under current SharePoint Site for hosting YAF.

Some modifications need to be done in  config file for this to work, below are some of them

  • Move provider’s declarations (membership,roleManager and profile) from web.config in {hive}\layouts\yaf to   C:\inetpub\wwwroot\wss\VirtualDirectories\{Port}
  • Set  parameters YAF.FileRoot & YAF.AppRoot to  ~/_layouts/yaf

2) For solution to be truly integrated with YAF we need  mechanism to enable auto registerstration of SharePoint users in YAF (through standard YAF membership provider)

Prerequisites:

Windows authentication is used.

<authentication mode=”Windows” />
<identity impersonate=”true” />

To enable SharePoint users to be created automatically in YAF lets create YAF module

Below is full source code for module

[YafModule(“Microsoft Sharepoint To YAF Users Synchronization Module”, “vgrem”, 1)]
public class SPS2YAFUsersSyncModule : SimpleBaseModule
{
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref=”SPS2YAFUsersSyncModule”/> class.
/// </summary>
public SPS2YAFUsersSyncModule()
{
}
#endregion
#region Public Methods
/// <summary>
/// The init forum.
/// </summary>
public override void InitForum()
{
this.PageContext.PagePreLoad += new EventHandler<EventArgs>(this.PageContext_PagePreLoad);
}
#endregion
#region Methods
/// <summary>
/// The page context_ page pre load.
/// </summary>
/// <param name=”sender”>
/// The sender.
/// </param>
/// <param name=”e”>
/// The e.
/// </param>
private void PageContext_PagePreLoad(object sender, EventArgs e)
{
Page curPage = this.PageContext.CurrentForumPage.Page;
if (
(curPage.User.Identity.AuthenticationType == “NTLM”)
|| (curPage.User.Identity.AuthenticationType == “Negotiate”)
// || ( Context.User.Identity.AuthenticationType == “Windows” )
)
{
if (CurrentYAFUserName != curPage.User.Identity.Name)
{
ProcessYAFMembershipLogin(curPage.User);
CurrentYAFUserName = curPage.User.Identity.Name;
}
}
}
/// <summary>
///
/// </summary>
/// <param name=”p”></param>
private void ProcessYAFMembershipLogin(IPrincipal p)
{
string email = p.Identity.Name + “@company.ru”;
string userName = p.Identity.Name;
int boardID = YafContext.Current.PageBoardID;
MembershipCreateStatus status;
string question = “Company”;
string answer = “Company”;
bool approved = true;
MembershipUser user;
//if(UserMembershipHelper.GetUser(false) != null)
if (!UserMembershipHelper.UserExists(userName, email))
{
// create a new user and generate a password.
int retry = 0;
do
{
string newPassword = Membership.GeneratePassword(7 + retry, 1 + retry);
user = YafContext.Current.CurrentMembership.CreateUser(
userName, newPassword, email, question, answer, approved, null, out status);
}
while (status == MembershipCreateStatus.InvalidPassword && ++retry < 10);
if (status == MembershipCreateStatus.Success)
{
// setup inital roles (if any) for this user
RoleMembershipHelper.SetupUserRoles(boardID, userName);
// create the user in the YAF DB as well as sync roles…
int? userID = RoleMembershipHelper.CreateForumUser(user, boardID);
// create profile
YafUserProfile userProfile = YafUserProfile.GetProfile(userName);
// setup their inital profile information
userProfile.Location = string.Empty;
userProfile.Homepage = string.Empty;
userProfile.Save();
YafBuildLink.Redirect(ForumPages.forum);  //Force to reload page for new user
}
}
}
#endregion
#region Properties
private string CurrentYAFUserName
{
get
{
if (HttpContext.Current.Session[“yafUserName”] != null)
return (string)HttpContext.Current.Session[“yafUserName”];
return string.Empty;
}
set
{
HttpContext.Current.Session[“yafUserName”] = value;
}
}
#endregion
}
You may create separate assembly for this module, but you must meet  some requirements for YAF engine to load your module:
  • your assembly name need start with YAF and  SPS2YAFUsersSyncModule
  • class need to be located in YAF.Modules namespace.

Now you should be able to use YAF from SharePoint

That’s all for now.
In next post we’ll take a look at some ways to improve our solution such as
  • implement Forum scopes between SharePoint sites (isolation forums for different sites)
  • create Site Definitions for forum
  • web part for using in Site page