Posts

JQuery: Get Rid off SharePoint Spell Check

Hi Guys, After spending 3-4 hours of struggle, I finally found way to get rid off irritating SharePoint Spell checker. It caught people picker too under the umbrella of spell check, but why, usually it does not required. Well again it may be the requirement. But for my case, I don't want it to watch any of my control on whole site. I tried to navigate to Manage Farm Features > Spell Check feature. Even after deactivating this feature it still working like a stubborn functionality. Then I realized that nothing is impossible for a developer. I have JQuery with me I can hide that control. Resolution: 1) Hiding spell check from the Ribbon: in order to hide the spell check feature to end user, trick that worked for me is to add following line in my custom js: $('a:has(img[src*="images/spellingHH.png"])').parents("li").hide(); 2) Exclude fields from the spell check feature: I have created follwoing method to exclude people picker and other inputs fields fro...

Powershell: Change Like and comments settings of a library

Hi, Recently I was working on the requirement to enable the like and comments settings of any library. So I prefer to use PowerShell script for same. I am sharing the code as below: function Change-SettingsForLikeComment() { # Change page library settings for Likes and comments $list=$web.Lists["Pages"]; if($list -ne $null) { Write-Host $list.Title "not null"; $assembly=[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") $reputationHelper =$assembly.GetType("Microsoft.SharePoint.Portal.ReputationHelper"); $bindings = @("EnableReputation", "NonPublic", "Static"); [System.Reflection.BindingFlags]$flags = [System.Reflection.BindingFlags]::Static -bor [System.Reflection.BindingFlags]::NonPublic; $methodInfo = $reputationHelper.GetMethod("EnableReputation", $flags); #For enabling Ratings #$values = @($list, "Ratings", $fa...

Powershell: Update "Subsite Templates" under AreaTemplateSettings.aspx

Hi, This time I am discussing about how one can update the "AvailableWebTemplates" once you have created a site. Just for the information, we can define this property in Onet.xml while creating any new site. But what if you have created sites, sub sites underneath and sub sub sites underneath, in that case you need a power shell script to update all those values. Background: This property is defined in Onet as shown below: <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416"> ----------------- <Property Key="AvailableWebTemplates" Value="*-CMSPUBLISHING#0;*-BLANKINTERNET#2;*-ENTERWIKI#0;*-SRCHCEN#0"/> --------------------- </Feature> But once site is created using this site template, we have to dig down to update this. Using power shell its quite easy task provided you must know the Id and template name. Work Arround: We using the below mention code we can override the web template property. In order to update that we must know th...

Display Template Deployment in SharePoint 2013

Hi Guys, New way to transform search result introduces in SharePoint 2013 which provide a good user experience through the use of display templates. It is far better then using XSLT in SharePoint 2010 to use to customize that display. It is really frustrating while understanding XSLT display templates. The great thing about display templates is that you create them by leveraging skills that many developers already possess: HTML and JavaScript. The most likely approach to creating display templates is to start with an existing display template HTML file and customize it. It’s not too difficult when you get the hang of the _#= (underscore pound equals) syntax. It’s very important to understand what happens when you edit that HTML file. When you click save SharePoint creates a JavaScript file and associates the two together. (The same thing happens when creating master pages using the design manager but HTML to MASTER file). When you select your display template in the content by search w...

Custom Site action using MenuItemTemplate

Hi, Site action links are by default added by sharepoint but there could be some cases when you feel like adding new site action to navigate to your custom page or OOB page. In this blog, I will explain how you can and what are the various way to do that. Solution 1 (Using Custom Action): You must heard this term if ever got chance to customize the ribbon or any contextual menu. You can very easily add this element to your custom farm solution just by adding a empty module and then add following code in to it. <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="CustomScript" ScriptBlock="function OpenDialog() { window.scrollTo(0, 0); var context = SP.ClientContext.get_current(); var siteUrl = context.get_url(); if (siteUrl == '/') siteUrl = ''; var options = SP.UI.$create_DialogOptions(); options.url = siteUrl + '/_layouts/<url of your cust...

Create Metadata terms structure with CSV using Powershell

Tagging content is very important feature in SharePoint. This post will help you if you are planing to use tags and for initial configuration you don't want your client to manually create the 1000 of tags with a defined structure. So first thing needed to built this is well defined structure of the terms in Excel file. So that you can easily create CSV file from Excel. While creating this excel file make sure that all the terms you enter this should comes under ONE TERM SET. For other terms set you will be needing another csv file. You can take help from this sample csv file for creating site structure. Next, is to open the PowerShell and write some code. Below is the code functions used for importing excel file. function ImportTermSet([Microsoft.SharePoint.Taxonomy.TermStore]$store, [string]$groupName, [PSCustomObject]$termSet) { function ImportTerm([Microsoft.SharePoint.Taxonomy.Group]$group, [Microsoft.SharePoint.Taxonomy.TermSet]$set, [Microsoft.SharePoint.Taxonomy.Term]$paren...

Get Comment Count in SharePoint

Hi Guys, In this blog I will explain how we can get the number of comments on any page/article. Prerequisites for this blog are: a list with rating enabled, an article/page/splistItem already have got comments from users and a tool like VS to code ;) According to requirement it may be the case that one need to get item comment count using java script or c#. I will explain both way to get the comment count: Using Javascript: This may be the case when one want to use the content search webpart or CQWP to display comment count. Followng code can be use to get the comment Count: var linkURL = $getItemValue(ctx, "Link URL"); linkURL.overrideValueRenderer($urlHtmlEncode); // Get the Comments count var soapEnv = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \ <soap:Body>    \ <CountCommentsOnUrl xmlns='http://mi...