Working with related data in search-driven publishing with Mavention Related Data


When publishing content using search-driven publishing you might want to combine data from multiple sources. Find out how to simplify working with related data using Mavention Related Data.

SharePoint 2013 Search-driven publishing

One of the new web content management capabilities in SharePoint 2013 is search-driven publishing. Leveraging the capabilities of the enterprise-class SharePoint 2013 search engine it not only allows you to cross the Site Collection-boundary for publishing content but also to build truly intelligent websites. The analytics capabilities of SharePoint 2013 Search make it possible for you to target content based on your visitors’ click behavior or their personal profile. As a result you can serve them more relevant content increasing the conversion rate from your website.

Often in search-driven publishing scenarios content is stored in one or more catalogs. SharePoint 2013 Search indexes that content and makes it available for publishing on one or more websites. Although search-driven publishing offers great flexibility for publishing content it introduces a challenge when it comes to publishing content merged from multiple catalogs.

To illustrate this problem let’s take a look at two examples from the mavention.com website.

Loading Maven tile on blog posts

When reading a blog post on mavention.com on the right-hand side the tile with the author information is displayed.

Arrow pointing to author information on a blog post on mavention.com

This information is loaded from the Maven page also coming from the same catalog and published on mavention.com.

Maven page on mavention.com

Obviously you wouldn’t want to include and maintain the same information on every blog post. Instead you would want SharePoint to load the information for the author of the current page automatically for you. Unfortunately, as SharePoint 2013 Search doesn’t support joins, there is no easy way to do this.

To load Maven information on blog posts on mavention.com we’re using the SharePoint 2013 Search REST API. Once the blog post page is loaded we use the name of the author (which is stored together with the blog post) to execute another search query to retrieve the Maven information. Because the name of the blog post’s author is known only very late in the page rendering process, we chose to load the Maven information client-side using a REST request not to further delay loading the page.

Loading Google Authorship information

A while ago Google announced support for publishing authorship information. Whenever you search for something and Google finds a result with the authorship information published you will see the author’s picture and name next to that search result.

Search result from this blog with the authorship information displayed

One of the configuration steps required for the authorship information to be displayed by Google is to provide a link to your Google+ profile. Once again, the link to the Google+ profile is something that you would want to store centrally and have it loaded whenever necessary.

Although this scenario resembles loading Maven information on the blog post page, there is one big difference. Google must be able to index the link to your Google+ Profile and that link must therefore be a part of your HTML rather than being loaded dynamically using AJAX. So if making a REST call isn’t an option, how to load the related data from the Maven page and make it available server-side so that it can be rendered as a part of the page’s HTML?

One way, that you could think of, to load the related data server-side could be to execute another search query to load the Google+ profile URL using the name of the author from the initial search query. Although it would provide the desired results, it would have a significant impact on the performance of your website. Luckily there is a better way to load related data in search-driven publishing scenarios.

Mavention Related Data is a solution designed to help you work with related data in search-driven publishing scenarios in SharePoint 2013. By linking multiple items to each other, it automatically loads the related data making it available for SharePoint 2013 Search. When working with Mavention Related Data the related data becomes a part of the item which solves the challenge of crawling and linking it to the particular item. To leverage Mavention Related Data all you need to do is to link the item to the item containing related data and from that moment Mavention Related Data will automatically load and refresh related data on each change of either the source or the target item.

Publishing Google+ profile URL on a blog post on mavention.com

To illustrate the working of Mavention Related Data let’s take a step-by-step look at how we’ve used it on mavention.com to publish Google+ Profile URL as a part of a blog post page.

We started with installing the Solution package and activating the Mavention Related Data Site Collection Feature.

Next, we extended our Content Types to be able to link items together and store the Google+ Profile URL. To link to the Maven page we created a new column called Contact Profile Page of type Hyperlink.

Important: Using the Hyperlink field type is required for the items to become linked.

Configuration of the Contact Profile Page column in SharePoint 2013

Next we added another column called Google Plus Profile Url of type Text.

Configuration of the Google Plus Profile Url column in SharePoint 2013

With the Content Types extended we proceeded with linking content pages to Maven profile pages.

On each page on mavention.com we have its author’s name stored in plain-text in the Contact Name (PublishingContactName) column.

Contact name stored with pages on mavention.com

Using the following PowerShell script we prepopulated the links between items and the Maven profile pages:

$web = Get-SPWeb https://authoring.mavention.nl/nl-nl
$list = $web.Lists['Pages']
$listItems = $list.Items
$listItems | % {
    $item = $_
    Write-Host "Processing page $($item.Url)"

    $authorName = $item['PublishingContactName']
    if ($authorName -ne $null -and $authorName -ne '') {
        Write-Host "Looking for author profile for $($authorName)"

        $query = New-Object Microsoft.SharePoint.SPQuery
        $query.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>$($authorName)</Value></Eq></Where>"
        $items = $list.GetItems($query)
        if ($items.Count -eq 1) {
            Write-Host "Profile page found. Linking item..." -NoNewline

            $relatedItem = $items[0]
            $absoluteUrl = $relatedItem.Web.Url.TrimEnd('/') + '/' + $relatedItem.Url
            $item['ContactProfilePage'] = $absoluteUrl
            $item.SystemUpdate($false)

            Write-Host "DONE" -ForegroundColor Green
        }
        else {
            if ($items.Count -eq 0) {
                Write-Host "No profile page found for author $($authorName)"
            }
            else {
                Write-Host "Found more than one profile page found for author $($authorName)"
            }
        }
    }
    else {
        Write-Host "No author specified"
    }
}

Content pages linked to the Maven pages using page author information

Next, on the List Settings page of the Dutch Catalog (Pages Library) we opened the Related data settings page.

Related data link highlighted on the List Setting page

On the Related data settings page we enabled monitoring changes to the related content and configured mappings between the source field that contains Google+ Profile URL of each Maven and the field to which that URL should be copied. To keep things simple we use one and the same field.

Related Data configuration for the Google+ Profile URL on mavention.com

Having saved the changes we proceeded with updating the Google+ Profile URLs on Maven pages:

Adding Google+ Profile page URL to the Maven profile page

After saving the changes Mavention Related Data automatically copied the Google+ Profile URL from the Maven profile page to all other pages created by that Maven. Because we added a new column, we had to perform a Full Crawl to have SharePoint create and populate the new Managed Property. The last step was to use the Catalog Item Reuse Web Part to have the Google+ Profile URL rendered as a meta tag in the Master Page.

Google authorship information displayed in the Google Structured Data Testing Tool

Even though we are using a single catalog on mavention.com where both the source and the related items are stored, Mavention Related Data allows you to link items together from different lists as long as they both reside in the same Site Collection.

Summary

Search-driven publishing is a new content publishing model provided with SharePoint 2013 that allows for flexible content publishing. Although very flexible and powerful, one of the challenges when working with search-driven publishing is publishing related content. In the example above you have seen how you can leverage the Mavention Related Data solution to publish data from separate catalogs as a single page using SharePoint 2013 search-driven publishing. Publishing authorship information is just one example but there are more scenarios to which this approach is applicable.

Download: Mavention Related Data (6KB, WSP)

Others found also helpful: