Skip Ribbon Commands
Skip to main content

:

Home
March 22
SharePoint 2010 search ranking model – QueryDependantFeatures

 

1: <rankingModel name=“stringid=“GUIDdescription=“stringxmlns=“http://schemas.microsoft.com/office/2009/rankingModel>

   2:      <queryDependentFeatures>
   3:          <queryDependentFeature pid=“PIDname=“stringweight=“weightValuelengthNormalization=“lengthNormalizationSetting/> 
   4:      </queryDependentFeatures>
   5:      <queryIndependentFeatures>
   6:          <categoryFeature pid=“PIDdefault=“defaultValuename=“string>
   7:              <category value=“categoryValuename=“stringweight=“weightValue/> 
   8:          </categoryFeature>
   9:          <languageFeature pid=“PIDname=“stringdefault=“defaultValueweight=“weightValue/>
  10:          <queryIndependentFeature pid=“PIDname=“stringdefault=“defaultValueweight=“weightValue>
  11:              <transformRational k=“value/>
  12:              <transformInvRational k=“value/>
  13:              <transformLinear max=“maxValue/>
  14:          </queryIndependentFeature>
  15:      </queryIndependentFeatures>
  16:  </rankingModel>
  17:   

Le contenu XML ci-dessus est celui utilisé sur MSDN pour présenter le Ranking Model schema de SharePoint 2010.
Dans ce post, nous allons décrire le noeud QueryDependentFeature:

 

Comme son nom l’indique, ce noeud va permettre de traiter les éléments provenant de la recherche faites par l’utilisateur. Autrement dit : comment pondérer les différents termes passés au moteur de recherche SharePoint.

Le premier attribut “pid” est obligatoire et permet de définir l’ID de la managed property pour la quelle on veut changer la pondération.
Le deuxième attribut “name” n’est pas obligatoire mais permet de spécifier le nom de la managed property 
l’attribut suivant est ”weight”, il est obligatoire et sert à définir l’importance de la property dans la recherche
Pour terminer, l’attribut “lengthNormalization”  quand a lieu est utile pour garder un “équilibre” entre les champs de différentes tailles

Voici la commande powershell qui vous permet d’obtenir la liste des managed property et leurs pid

   1:  Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchMetadataManagedProperty

Exemple d’utilisation de QueryDependantFeature

   1:  <queryDependentFeatures>
   2:       <queryDependentFeature pid=”56name=”Filenameweight=”75lengthNormalization=”75/>
   3:       <queryDependentFeature pid=”11name=”Landweight=”70lengthNormalization=”70/>
   4:  </queryDependentFeatures>
February 13
Migrating Enterprise SharePoint 2007 Approval workflow to SharePoint 2010

Few days ago, I been facing a issue with approval workflow created in SharePoint and migrate to SharePoint 2010.
Technically everything is working fine, I mean the workflow continue to work like before in SharePoint 2010 with exactly the same forms and behavior. You should ask yourself : “what’s wrong so ?”

The problem is more in term of “consistency”. Indeed if you create new workflow in your site you will not be able to select the SharePoint 2007 approval workflow template (Even by activating the “SharePoint 2007 feature” on the site collection level) only the SharePoint 2010 version will be able.

Even if the behavior is the same, the two workflow doesn’t use the same form layout. It means for the end two different experience, that’s probably not what you want.

However,  even if you cannot select the “old” template via the SharePoint web interface, you still able to associate it with a list via the SharePoint API. Simply because of the backward compatibility of the SharePoint assemblies.

So the two solutions I found was :

  • Replace all the 2007 workflows by the new SharePoint 2010 approval workflow
  • Associate the new workflow to list using the SharePoint SDK
February 09
Powershell: How to unzip a file ?

Here is a simple way to unzip a file using Powershell

   1:  $app=new-object -com shell.application 
   2:  $zip = $app.namespace("c:\filetounzip.zip") 
   3:  $target = $app.namespace("c:\targetDirectory") 
   4:  $target.Copyhere($zip.items())

This script is taking a file named filetounzip.zip located in the root of C drive and unzip it in the folder c:\targetDirectory

Extremely simple Winking smile

February 09
Powershell: How to add a page layouts in the available page layout collection ?


In a SharePoint publishing site administrators have the possibility to define a list of page layouts that author can use to create page. This function allow you to add a new page layout in this collection

   1:  function AddPageLayoutAsAvailablePageLayout([Microsoft.SharePoint.Publishing.PublishingWeb] $pubWeb, [Microsoft.SharePoint.Publishing.PageLayout] $pl)
   2:  {
   3:      $type = [Type] $pl.GetType()
   4:      $genlist = [System.Collections.Generic.List``1]
   5:      $gentype = $genlist.MakeGenericType(@($type))
   6:      $instance = [Activator]::CreateInstance($gentype)
   7:      $instance.AddRange($pubWeb.GetAvailablePageLayouts())
   8:      if (-not $instance.Contains($pl)){
   9:          $instance.Add($pl)
  10:      }
  11:      $pubWeb.SetAvailablePageLayouts($instance.ToArray(),$false)
  12:      $pubWeb.Update()
  13:  }

Where:

  • $pubWeb is the PublishingWeb object representing the Publishing site where the page layout should become available
  • $pl is the PageLayout object representing the page layout to add in the available page layout collection

Example:

   1:  $web = Get-SPWeb "http://......."
   2:  $site = $web.Site
   3:  $psite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
   4:  $pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($w)
   5:  $pagelayout = $psite.PageLayouts["/_catalogs/masterpage/xxxxxxxxx.aspx"]
   6:  AddPageLayoutAsAvailablePageLayout $pweb $pagelayout
 
don’t forget to finish by disposing object
February 09
Powershell: How to change page layout content type ?


This function change the content type attached to a page layout

   1:  function AttachContentTypeToPageLayout([Microsoft.SharePoint.Publishing.PageLayout] $pl, [Microsoft.SharePoint.SPContentType] $ct)
   2:  {
   3:      $file = $pl.ListItem.File
   4:      if ($file.CheckOutType -eq "None")
   5:      {
   6:          $pl.ListItem.File.CheckOut()
   7:      }
   8:      
   9:      $pl.AssociatedContentType = $ct
  10:      $pl.Update()
  11:      $file.CheckIn("Page Layout update")
  12:      $file.Publish("Page Layout update")
  13:      $file.Approve("Page Layout update")
  14:      
  15:  }

Where:

  • $pl is a PageLayout object representing the publishing page layout to update
  • $ct is a SPContentType object representing the content type to attach to the page layout

Example:

   1:  $web = Get-SPWeb "http://......"
   2:  $site = $web.Site
   3:  $psite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
   4:  $pagelayout = $psite.PageLayouts["/_catalogs/masterpage/xxxxxxxxxx.aspx"]
   5:  $ctid = New-Object Microsoft.SharePoint.SPContentTypeId("0x0xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
   6:  $ct = $web.ContentTypes[$ctid]
   7:  AttachContentTypeToPageLayout $pagelayout $ct

 

don’t forget to finish by disposing object
February 09
Powershell: How to add site column in a content type ?


This function add an existing site column to a content type

   1:  function AddSiteColumnToContentType([Microsoft.SharePoint.SPField] $sc, [Microsoft.SharePoint.SPContentType] $ct)
   2:  {
   3:      $flink = new-Object Microsoft.SharePoint.SPFieldLink($sc)
   4:      $flink.DisplayName = $sc.Title
   5:      if (-not $ct.Fields.Contains($sc.Id))
   6:      {
   7:          $ct.FieldLinks.Add($flink)
   8:          $ct.Update($true)
   9:      }
  10:  }

Where:

  • $sc is a SPField object representing the Site column to add in the content type
  • $ct is a SPContentType object representing the content type to update
February 09
Powershell : How to create a site column ?


The following function can be used to create site column on a SharePoint site

   1:  function CreateSiteColumn([Microsoft.SharePoint.SPWeb] $web, [string]$fieldname, [string]$fieldtitle, [Microsoft.SharePoint.SPFieldType] $fieldType, [string] $group)
   2:  {
   3:      $alreadyExist = $web.Fields.ContainsField($fieldname)
   4:      if (-not $alreadyExist)
   5:      {
   6:          $scname = $web.Fields.Add($fieldname, $fieldType, $false)
   7:          $sc = $web.Fields[$scname]
   8:          $sc.Title = $fieldtitle
   9:          $sc.Group = $group
  10:          $sc.Update()
  11:          return $sc
  12:      }
  13:      else
  14:      {
  15:          return $web.Fields.GetFieldByInternalName($fieldname)
  16:      }
  17:  }

 

Where :

  • $web is the SPWeb object where the site column need to be created
  • $fieldname is the name of the new field
  • $fieldtitle is the display name of the new field
  • $fieldType is a SPFieldType object describing the column type
  • $group is the title of the group that will contains the new field

Example:

   1:  $web = Get-SPWeb "http://........"
   2:  CreateSiteColumn $web "My_New_Field" "My new field" ([Microsoft.SharePoint.SPFieldType]::Integer) "MyGroup" 
February 08
Show or hide SharePoint 2010 ribbon based on SharePoint groups

I released a solution to allow administrator to define who can or cannot see the SharePoint ribbon.
With this solution you can on each site define if the ribbon is display or not for:

  • Everyone
  • Anonymous user
  • for one or many specific SharePoint groups

screen1  screen3

On site level, you can define for which groups the ribbon is displayed, subsites can inherits the same settings :

screen2

The solution and the sources can be downloaded on codeplex

February 08
Google analytics connector for SharePoint 2010


I released a new open source project on Codeplex. It allow administrators to connect a SharePoint site to a Google analytics account to get advanced usage reporting.

SiteAdminMenu AccountSettings

The profile ID can be defined on site level. You can also define the settings on the top site level only.

That’s all, nothing more to do to get advanced usage reporting of your site.

Analytics

 

The SharePoint solution package and the sources is available on codeplex

 

 About ConsultPoint

 

ConsultPoint is a consultancy company specialized in Microsoft SharePoint technologies. 

ludovic@consultpoint.net
Phone: +32 497 67 33 33

 

 

 Microsoft MVP

 
Microsoft_MVP_logo.png

 

 Books

 
51GTEMXRl4L__AA115_.jpg

51WnkCjgA6L__SL160_PIsitb-sticker-arrow-dp,TopRight,12,-18_SH30_OU08_AA115_.jpg

 

 Open sources project