Monday, 23 March 2015

Exploring “Popular Items” Search web part

Hi All,

Today new interesting point in SharePoint 2013 :).

I was exploring the “Popular Items” web part and I want to see on which managed property this web part does the sorting. I have added it on my page.

Figure 1 : Popular Items web part

I edited this web part and found that there is no “SORTING” tab and no link to “Switch To Quick Mode / Switch to Advanced Mode” available.

Figure 2 : Query Builder of Popular Items web part

So here my curiosity increased J I then added the “Content Search” web part

Figure 3 : Content Search web part

I edited this web part and found that there those respective settings (“SORTING” tab, and link to “Quick Mode / Advanced Mode”) are available as

Figure 4 : Query Builder of Content Search web part

This is quite interesting.  So I exported the both web parts and started comparing and found the difference as

Figure 5 : UseSimplifiedQueryBuider property  - difference in normal Content Search and Popular Items web part

Popular Items web part nothing but the Content Search web part with very few differences. There is property called “UseSimplifiedQueryBuider” which determines visibility of “Advanced Mode”.

If we export “Popular Items” web part change this property from “True” to “False”, upload again and adds on page it shows the respective options and then I can see the “SORTING” tab and “Advanced Mode” link J


I’ll continue posting such kind of interesting facts :)

Feel free to comment /suggestions / feedback J

Saturday, 14 March 2015

Setting available page layout to existing sites using PowerShell

Hi Again,

In our project we had a requirement to available new page layout along with the existing available page layouts. Basically we need to update the available page layouts. 

Since we need to make page layout available on existing sites, only option we have is PowerShell script. 

Here I’ll share the detailed steps and script

Following are the high level steps

  1.   Get the Web (SPWeb) instance
  2. Get Publishing web instance
  3. Get the collection of currently available page layouts
  4. Get Publishing site instance
  5. Get all page layouts collection from publishing site
  6. Loop through all the page layouts check for the page layout which we need  to make available 
  7. If page layout found then add it to the collection of current site page layouts
  8. Update the publishing web instance

function SetAvailablePageLayout($webUrl, $pageLayoutName)
          #web instance
          $web = Get-SPweb $webURL
          #Log file path
          Start-Transcript $logfile

          #Publishing web instance
          $pweb =
         #getting current web available page layouts collection
          $currentLayOuts = $pWeb.GetAvailablePageLayouts()
          #site instance
          $site = $web.Site

          #publishing site instance
          [Microsoft.Sharepoint.Publishing.PublishingSite]$publishingSite = New-Object  

          #getting collection of all the page layouts in a Site collection
          $allPageLayouts = $publishingSite.PageLayouts

          #looping through all the page layouts
          foreach($pageLayout in $allPageLayouts){
           #checking for the page layout which we want to make available
            if($pageLayout.Name -eq $pagaeLayoutName)
              #adding the new page layout to current webs available page layout          
             } #if
          } #for each
          #updating available page layout collection of current site
} #function

Call to above function

SetAvailablePageLayout -WebURL "" -pageLayoutName "MyNewPageLayout.aspx"

Thanks  J

Feel free to comment /suggestions / feedback if any :)