SharePoint 2013 Content Editor – zero width space characters

Sometimes, the content editor web part of SharePoint 2013 adds unwanted characters to the text within it. You check once, twice, remove any unnecessary line breaks, spaces etc., but after saving or in the HTML source of the page you find these weird characters: ​ – the zero width spaces (& #8203;)

They can mess up your CSS layout, and frankly, I have not found a solution to force SharePoint not to insert them.

One possible workaround would be to remove them with a library like jQuery, e.g.

[javascript]

$(’.ms-rtestate-field’).each(function(index,element)  {
var theeditor = $(element);
$(theeditor).html($(theeditor).html().replace(/u200B/g,”));
});
[/javascript]

The selector applies to the content editor webpart of SP2013.

Hope this helps.
Łukasz

SharePoint 2013: Get item order ID in the search results display template

In SharePoint 2013, when creating a custom display template for an item, sometimes you need to know, which item in the whole search results list it is. In other words, you need the information of which item in the whole sequence that is, and perform your own logic according to the parameter.

I’ve looked for the property quite a while, but finally found it. It is called piSearchResultId.

Practically you can call it like that in your display template:

ctx.CurrentItem.piSearchResultId

It’s value is similar to the following:

0_1 for first item in the list
1_1 for the second item
2_1 for the third item
…and so forth.

With such values you can extract the first number, and there you go!

Hope this helps,
Lukasz