Umbraco is a really cool open source CMS released under MIT license. And with more than 85000 active installations I must say it’s a very impressing piece of work. Microsoft Office SharePoint Server (MOSS) and Windows SharePoint Services (WSS) is quickly becoming a dominate application for storing and maintaining enterprise data and intelligence for organizations of all sizes.
But, they don’t do together. There are a few ways of integrating and interfacing towards SharePoint but each and one of them requires you to either spend a lot of time understanding the MOSS/WSS data structure, naming conventions and data type conversion requirements. The developer also needs to understand the CAML (Collaborative Application Markup Language) syntax used to query lists and views. The code base tends to grow to a size that is not in proportion to the functionality.
This is a problem we used to have as well.
Watch the webcast in how to make a simple integration between SharePoint and Umbraco
In this demo we simply pull the data from a SharePoint list to a specific Umbraco template. The data is pulled every time some one requests the page.
Setting up SharePoint
- Create a list called something like “SharePoint Articles”
- Create two extra columns, Article and Publish to external
- Article: Use “Multiple lines of text” and uncheck the “Add to default view”
- Publish to external: Use “Yes/No (check box)”, make sure the “Add to default view” is checked
- Create some articles
When you are done it should look something like this
Building the Umbraco macro
Create a standard ASP.NET Web Application in Visual Studio 2010, throw away everything except the project file and create a “New Item” > “Web User Control”. I named mine to UmbracoCamelotDemo.
This is the file that renders the content to Umbraco. You should have one line in it, the <%@ Control. We must add an asp:Panel to display our data.
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="UmbracoCamelotDemo.ascx.vb" Inherits="UmbracoCamelotDemo.WebUserControl1" %> <asp:Panel ID="Panel1" runat="server"></asp:Panel>
The code behind file …
Public Class WebUserControl1 Inherits System.Web.UI.UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString As String = "Server=yourserver;Database=;Domain=;User=sharepointuser;"_ "Password=sharepointpassword;Authentication=Ntml;TimeOut=10;strictmode=false;recursivemode=recursiveall;"_ "defaultlimit=1000;cachetimeout=5;MaxReceivedMessageSize=10000000;MaxBytesPerRead=10000000" Dim conn As New Camelot.SharePointConnector.Data.SharePointConnection(connectionString) Dim query As String = "SELECT ID, Title, Article FROM `SharePoint articles`.all WHERE `Publish to external` = 1" Dim adapter As New Camelot.SharePointConnector.Data.SharePointDataAdapter(query, conn) Dim dtMyWebPartList As New DataTable() adapter.Fill(dtMyWebPartList) For Each row As DataRow In dtMyWebPartList.Rows Dim c As New System.Web.UI.WebControls.Label c.Text = "<h2>" + row.Item("Title").ToString + "</h2>" c.Text += row.Item("Article").ToString Panel1.Controls.Add(c) Next End Sub End Class
Build, deploy and show
Simply build the files and deploy them in Umbraco
- Put UmbracoCamelotDemo.ascx in the /usercontrols directory in the Umbraco web root
- Put the UmbracoCamelotDemo.ascx.vb file in the /bin directory in the Umbraco web root.
Add the macro in the Umbraco admin interface
- Navigate to the Developer section
- Right click Macros and select create
- Type CamelotDemo as name (Or what ever suits you best, this can be changed afterwards)
- Use the list “Browse usercontrols on server…” and select your usercontrol there.
Navigate to the settings section and create a new template, or modify an existing. This example creates a new template
- Right click the Master page and select Create
- Add any elements you prefer here and the macro, I’ve posted my page code below. To add a macro click the macro button and select your macro
<%@ Master Language="C#" MasterPageFile="~/masterpages/RunwayMaster.master" AutoEventWireup="true" %> <asp:Content ContentPlaceHolderID="RunwayMasterContentPlaceHolder" runat="server"> <div id="content"> <umbraco:Item runat="server" field="bodyText" /> <umbraco:Macro Alias="CamelotDemo" runat="server"></umbraco:Macro> </div> </asp:Content>?
You must also add the new template to a document type
- Expand the document types and select the document type you want to link i to (or allow it from)
Create the page SharePoint Articles
- Navigate to the content section
- Create a new page, name it and select the document type you linked your template to
- Enter some body text if you like and go to the properties tab
- Select the template you created
- Save and publish
You should now have a live view of your articles stored in SharePoint in Umbraco
Thanks for reading, please leave a comment or contact us at email@example.com