Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, August 16, 2017

Sitecore bug: Clone item with language fallback

I have checked this in Sitecore 8.1 and 8.2. Sitecore support team accepted it as a bug.

Here is the bug details:

If you have any item with language fallback and now if you create a clone of this item then you will not get language fallback on clone item. Instead of that you will get language version on clone item.

Here are steps to reproduce it
  • Let’s suppose you have 3 languages – English, French and German.
  • Both French and German languages are fallback to English.
  • Create an item where French is fallback to English and German have 2 versions as

Original Item with language fallback
Original Item with language fallback
  • Now create a clone of this item as
Clone item with language versions
  • As you can notice from image, French is not fallback to English on cloned item, instead an actual French version of the item is created.
  • Also we have 2 versions of German in original item but in clone item, only a single German version is created. This single version of cloned German is pointing to latest version of Original German item i.e. version 2.
  • You can verify this from “Create from” label and “Advanced/Source” field as highlighted in above image. As per Sitecore this “Single German Version” is expected behavior but French fallback Vs its version is a bug.
Sitecore had provided a patch for this bug for one of our project in Sitecore 8.1. But when I tested it in Sitecore 8.2, I am able to reproduce this.

Those who have multi lingual site, clone and fallback items should check this in their environment.

Please leave your comments or share this bug details if you care for any related Sitecore project.

Sunday, August 13, 2017

How to render Brightcove video programmatically using sitecore item




Brightcove and Sitecore using CSharp
Brightcove and Sitecore using CSharp


It’s very easy to render Brightcove video through HTML as

<iframe src="//players.brightcove.net/4234/default_default/index.html?videoId=1111" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>

But do you know how to render it through programmatically?

Let’s suppose you are getting video item id and player id through Sitecore in your MVC view as

var playerHtml = string.Empty;
<div>
@{
    playerHtml = HelperClass.Instance().GetVideoPlayerMarkup(Model.VideoItemGuidId, Model.PlayerGuidId, 170, 300);
}
<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
@Html.Raw(playerHtml)
<script type="text/javascript">
    brightcove.createExperiences();
</script>
</div>

This view calling GetVideoPlayerMarkup() method which accept 4 parameters – video item id, player item id, video player’s height and width.

You need to include below namespace for using this method

using Sitecore.MediaFramework.Pipelines.MediaGenerateMarkup;
using Sitecore.MediaFramework.Players;

Here is a C# code for this method as

public virtual string GetVideoPlayerMarkup(ID videoItemId, ID playerItemId, int height, int width)
{
    var playerHtml = string.Empty;
    PlayerProperties playerProperties = new PlayerProperties()
    {
        ItemId = videoItemId,
        PlayerId = playerItemId,
        Height = height,
        Width = width
    };
    MediaGenerateMarkupArgs args = new MediaGenerateMarkupArgs()
    {
        MarkupType = MarkupType.Html,
        Properties = playerProperties
    };
    MediaGenerateMarkupPipeline.Run(args);
    if (!args.Aborted)
    {
        playerHtml = args.Result.Html;
    }
    return playerHtml;
}

That’s it. Now when you render this view you will get the Brightcove video on the browser.

I hope you like this Sitecore-Brightcove integration through code. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this code if it’s useful for you.

Monday, July 10, 2017

Fix : 'Lucene.Net.Index.MergePolicy.MergeException' occurred in Lucene.Net.dll


If you are using Lucene search in your Sitecore project, you may receive Visual Studio Just-In-Time Debugger window which ask you for debugging.

When you debug you may encountered that there is an exception 'Lucene.Net.Index.MergePolicy.MergeException' in Lucene.Net.dll.

What does 'Lucene.Net.Index.MergePolicy.MergeException' mean?

This issue is related with your current Sitecore indexing and current indexes are not in well format. This typically happen when you copy full website from one developer machine to another. Indexes on new developer machine will not be in sync with its Sitecore instance.

How to fix it?

Simply delete all directories and files from "Data\indexes" folder and regenerate indexes from Sitecore Control Panel. 

I hope you like this Sitecore tip. Stay tuned for more Sitecore related tips.

Till that happy Sitecoring :)

Please leave your comments or share this tip if it’s useful for you.