Distributed umbraco content

Lets assume that you have two umbraco instances

  • A delivery site – publicly accessible site with no access to the CMS admin screens
  • An authoring site – Usually an IP restricted site which has access to the CMS admin panel

Both of these sites will share the same data base and media library.

You have cached content within the application, anything from a list in a HTTP cache to media content and now the data has been updated in the CMS. You can see the content on the authoring site, but you cant see the content on the delivery site until the cache has expired.

There are two publishing events that you can use when updating content to refresh the caches on both instances

  • PageCacheRefresher.CacheUpdated
  • MediaCacheRefresher.CacheUpdated

 

Create a new ApplicationEventHandler in the site and add both of these methods in and expire your caches as required.

When the content is updated in the CMS on your authoring site, it will update the database and call events. This will then call your custom code to clear and rebuild your cache which will enable the delivery site to be updated when content is entered in authoring.

The documentation still needs updating here https://github.com/umbraco/UmbracoDocs/issues/324 

Azure search – Scoring profiles

A scoring profile allows Azure search to target and favor a combination of columns when searching for content.

Searching without a scoring profile lets Azure search calculate a score based on what it thinks the best match is. This produces a score against the search result and tells your what the most relevant item is.

To create a scoring profile, first log into the Azure portal and find the Azure search block and select the index of choice.

The opening blade will show you all of the properties of the index, including all of the scoring profiles. This is at the bottom.

azure_search_scoring_profile_100217
Available scoring profiles

Click the “Add scoring profile” button at the top

azure_search_scoring_profile_4_100217

name the new profile and a new profile will open in the blade

azure_search_scoring_profile_2_100217

Click on the weights button and select the filed and weighting against that field. The weights are between 0-10

azure_search_scoring_profile_3_100217

 

Save the profile to close the blade. In the prevous blade, click “Set as default” which will set the scoring as a default item. This means any search performed against the index will be run through this to ensure the results you are expecting match the criteria.

Wrapping an image with a link in Sitecore mvc

When wrapping an image with a link, you will need to pass the context into the field. In your view, put the following code.

 
@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc
@model Sitecore.Sharedsource.Mvc.Presentation.RenderingModel

@Html.Sitecore().BeginField("Link", Model.Rendering.Item, new { haschildren = true })
 @Html.Sitecore().Field("Image", Model.Rendering.Item)
 @Html.Sitecore().EndField()