Let’s Play Ball! XSP in SPO [Part 3]

Reading Time: 8 minutes

 

This is part 3 of a multi-part series on configuring Cross-Site publishing in SharePoint Online.

Note: at the time of this writing, Cross-site Publishing is available in the Education, E3, E4, and E5 plans of Office 365.

Continuing with our example of building a Baseball Player Catalog, it’s now time to connect to our published catalog from the consuming site and set up the pages to show the player information via Search web parts.

Remember we have previously added our team members as items into one of three content types (Coaches, Front Office Staff, Players) to the baseball team list on the authoring site collection and crawled the content. Below is a screenshot to indicate this is just a regular custom list that the content authors will use to keep the player catalog up-to-date.

AuthoringSiteListView

NOTE: I am not an experienced branding resource. I will show the basics of how you can customize search web parts to show the 3 types of content (Players/Coaches/Front Office Staff). You are only limited by your imagination and the expertise of your branding resource on how you want your returned search results to look.


STEP 1: Connect to the Baseball Team Catalog on the consuming site by navigating to Site Settings…Site Administration…Manage Catalog Connections.

CatalogConnectionSiteSetting
Select the Connect to a catalog… link.  A list of available published catalogs will be shown. Click the Connect hyperlink on the far right of the catalog you want to connect to.  In our case, we select Authoring Site – BaseballTeam with the URL of https://xxxxx.sharepoint.com/sites/authoring/Lists/BaseballTeam

STEP 2: Configure the catalog connection settings from the settings page as follows:

Integration Settings: by selecting the first option you will integrate the terms in the catalog into the navigation of the consuming site.  We want this so select that option.
ConnectionIntegration

 

Navigation Settings: make sure you select the right term level to start your hierarchy.  This will depend on your unique requirements on how you want your navigation to appear on your site. In our example, Team List is a parent term for Players, Coaches, and Front Office Staff so by selecting it below and NOT including it in the navigation we will have Players, Coaches, and Front Office Staff as our top-level navigation on the site.
NavigationSettingsCatalogConnection

 

Catalog Item URL Settings: we want the URLs to look like they’re on the consuming site and based on the URL settings defined in the authoring site collection we want the friendly URL as follows:
CatalogItemConnectionSettings

 

Page Settings: you can either allow SharePoint to automatically generate the page layout and page for you or create your own. To start, we’ll let SharePoint do the work for us so select the first options. We will create custom pages later in this post and will change the catalog to use them.
CategoryItemPageCatalogConnection

 

Click ok.  Once you do this, you will notice the consuming site is immediately connected to your catalog and your top-level site navigation should reflect the terms from the term set: Players, Coaches, and Front Office Staff with sub-terms of Catchers, DH, Infield, Outfield and Pitchers under Players.

TopNavWithChildTermsV2

As you select the terms you will notice the friendly URL generated for each page. Eg. instead of the usual URL you would see for a page:
you see a friendly URL like this: (the 4 at the end of the URL is the unique ListItemID which we configured during the catalog definition)

 


Auto-Generated Pages Explained

Without making any modifications to the generated pages you should see the items from the Baseball Team list showing on your consuming site as you select the different terms in the site navigation.

 

Here is the auto-generated category page when the Players term is selected from the navigation with no custom branding applied:
OriginalCategoryPage

 

… and if you select Stretch Donaldson from above, here is the auto-generated catalog item page that is displayed: (not acceptable to look at – the managed properties are coming into the search results which is great, however you will need to customize it for readability)
OriginalCatalogItemPage

 

As shown above, there are 2 pages automatically generated for you: the category page that is displayed when you select a term from the navigation and the catalogitem page that is displayed when you select a specific item from a category page. Both of these pages have a Content Search Web Part (CSWP) included on them configured to use the published catalog as a result source (the CSWPs will appear with this webpart title: $Resources:cms,WebPartZoneTitle_Dynamic ). The category page will be restricted by the current and child navigation terms as follows:
 CSWP-Query Settings

…whereas the catalogitem page will be restricted by the navigation term of current page and will have an additional filter configured that will pull the unique ListItemID from a URL token as follows:

CSWP-Query SettingsCatalogItem

The friendly URLs are generated based on the settings defined in the authoring site collection when the list was published as a catalog. The setting below in the Content Search web part query settings should already be selected based on that:

CSWP-URLRewriting

 


STEP 3: Verify Managed Properties previously created.

To bring in the custom site column values you initially created on your content types, they need to be generated as managed properties.  If your managed properties are not being returned in your consuming site collection, you may be missing some configuration. In SharePoint Online, it has been my experience that they are not automatically mapped to crawled properties or set to be retrievable by default.  I have had success by making these setting changes to each managed property you want to display on any search web part on consuming sites:
  1. Map to a crawled property
  2. Select the ‘Retrievable’ and ‘Safe’ options for sure on each managed property.
  3. In SharePoint Online I’ve also selected both ‘Searchable’ and ‘Queryable’ options on the managed property and have had success with that although I’m not sure they are required.

Re-crawl both the SharePoint list and site to pick up these changes. Once the content has been re-indexed you should now see all of these managed properties when you are customizing the search web parts.

idea

Use the SharePoint Search Query Tool to assist in troubleshooting your returned search results. It allows you to see all managed properties returned from a query.

 

We will now create custom search pages and customize the display templates for the search results so it looks … better. 🙂

STEP 4: Create Custom Display Templates

Starting with a display template that closely resembles the look you want, make a copy of it and rename it with a custom name.  By default, the auto-generated Category page will use the Item_PictureOnTop display template and the CatalogItem page will use the Item_Picture3Lines display template so you may want to start with them.

 

I will not go into the detail steps of customizing the display templates as there are numerous top-quality references out there to do that.  At a high-level:
  • Add all new managed properties you want to show in your search results to the <mso:ManagedPropertyMapping> section at the top of the display template.
  • Add any html, css, and javascript into the display template to display your content.

Upload your custom display templates to the MasterPage gallery in the Display Templates/Content Web Parts folder and ensure they are approved.


STEP 5: Create Custom Category and Item Pages

Create a custom category page using the Category-TeamList page layout.  Your page layout will be Category-TermSetName. By selecting this page layout, the breadcrumb navigation and search webpart will already be configured for you.

Edit the $Resources:cms,WebPartZoneTitle_Dynamic webpart on the page and adjust the display template setting to your custom template: (in our example, the custom display template name is Player Pick on top, 3 lines on bottom.

WebpartSettingsforCategoryCustomDisplayTemplate

Create a custom catalog item page using the same page layout (Category-TeamList).  I find this works well as it retains the breadcrumb navigation at the top of the page.

Edit the $Resources:cms,WebPartZoneTitle_Dynamic webpart on the page and change the query to have this configuration: (the unique ListItemID is retrieved from the URL to ensure we will only retrieve the 1 item selected)

CSWP-Query SettingsCatalogItem

 

You also need to adjust the display template so it points to your custom template: (in our example, the custom item display template is Player Pick on left, 3 lines on right.

WebpartSettingsforItemCustomDisplayTemplate


STEP 6: Point Navigation to Custom Pages

Now that you have built your custom pages, you need to connect them to your navigation terms since the auto-generated pages are currently connected. To do this, you go to Site settings…Term store management on the Consuming site collection.

In SharePoint Online, you need to change this setting in several places in the Site Navigation within the term store.

Term-Driven pages at the Site Navigation level:

SiteNavigationCustomPageSettings

Term-Driven pages at each top-navigation term level: (Coaches/Front Office Staff/Players):

CategoryNavigationPageSettings

 

Once you’ve done this, your custom pages will show when you click on any of the navigation terms on the consuming site collection.


STEP 7: Work is Done!

Here is an example of my custom category page when the Players term is selected from the navigation. You can see it displays all items underneath that term including all items associated to any of its child-terms using the custom category display template:

CustomCategoryPage

 

If you select a child navigation item (Players…Infield for example), the display is automatically filtered to only items for the Infield term and this is what you’ll see using the same custom category display template:

CustomCategorySubTermPage

 

 

 

 

 

…and if you select the infielder, Johnny Quick, from above, here is the custom catalog item page that is displayed using the custom catalog item display template:

CustomPlayerPageV2

 


SUMMARY

Well that’s pretty cool! We’ve isolated the authoring of the content from the look-and-feel of the content.  Content authors update information about team members on a custom list in one site collection and with some configuration and branding we surface the content in another site collection driven by term navigation and the power of SharePoint Search!

What’s next?

There are some nuances between building this solution in SharePoint Online compared to an on-premises SharePoint environment.  In the next post I’ll discuss some of these differences and some lessons learned along the way.

Thanks for reading!


Credits

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Icons by DryIcons

 

One comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.