Total Pageviews

25 Jun 2013

Managed metadata navigation and friendly URLs in Sharepoint 2013

Here is one of the three very good articles on new Managed Metadata features in SP 2013

Failed to create term set: A default managed metadata service connection hasn't been specified.

Here is a problem that might occur when dealing with Managed Metadata Service when trying to set up a Taxonomy-based navigation:
To fix this problem go to Central Administration, select your Managed Metadata Service (the second one on the screenshot) and make sure "This service application is the defaul storage location for column specifit term sets" is selected:

 
 

SharePoint 2013 What's new with WCM

Enabling HTML5 on SharePoint 2010 Master Page

This is the original article.

The steps are:
  1. Open your custom Master Page replace the existing DOCTYPE tag with the following HTML5 doctype: <!DOCTYPE html>
  2. Now look for the meta tag, X-UA-Compatible, found in the head section. It should look like: <meta http-equiv="X-UA-Compatible" content="IE=8" />
  3. Update the “content” value to "IE=Edge" 
That's it! now you can use lots of CSS 3.0 and HTML5 features.

19 Jun 2013

Using SVG Images with Modernizr.js

If you need to add an SVG to your HTML page here what you should do:

  • Install Inkscape (it's free to use).
  • Create SVG file
  • Export to PNG. This file will be used as a fallback in older browsers like IE 7 and IE 8
 
  • Create HML page and add .svg Image on it. Problem: IE8 does not support SVG. That's why you need modernizr.js
  • Include modernizr.js to the page. This will add "svg" or "no-svg" classes to the <HTML> tag.
  • Now you can use ".no-svg" and ".svg" classes in you CSS selectors to provide fallback to PNG images. In other words, you need to load .png images only when  no-svg class exists in DOM. 
Final HTML and CSS should be like following:
 
<style>
.svg .star-box{
   height: 48px;
   width: 52px;
   background: url("woman.svg") ;
   background-size: 100% 100%;
}.no-svg .star-box
{   background: url("woman.png") no-repeat;
   height: 68px;
   width: 48px;
   min-width: 1024px;
   background-size: 100% 100%;
}</style>

<div class="star-box"/>

So, when a browser supports SVG - .svg files will be used. If it does not it will fall back to using PNG.

14 Jun 2013

Changing SharePoint 2010 Favicion

In SharePoint Designer, open your current master page and change the following tag:
<SharePoint:SPShortcutIcon runat="server" IconUrl="/_layouts/images/yourFavicon/favicon.ico"/>

jQuery plugin for SharePoint 2010/2013 That turns on WYSIWYG Feature for Selected DIV Tags, Hack

Enable and disable native SharePoint WYSIWYG HTML Editor:

SharePoint 2010 Version:

 (function ($) {  
   $.fn.SPEditable = function () {  
     return this.each(function () {  
       $(this).addClass("ms-rtestate-write ms-rteflags-0 ms-rtestate-field").attr("role", "textbox").attr("aria-haspopup", "true").attr("style", "min-height: 84px;").attr("contentEditable", "true").attr("UseInlineStyle", "True").attr("aria-autocomplete", "both").attr("aria-multiline", "true");  
     });  
   };  
   $.fn.SPNonEditable = function () {  
     return this.each(function () {  
       $(this).removeClass("ms-rtestate-write ms-rteflags-0 ms-rtestate-field").removeAttr("role aria-haspopup style contentEditable UseInlineStyle aria-multiline");  
     });  
   };  
 })(jQuery);  

Usage:
 $("#myDiv").SPEditable();  

The result is amazing:
One thing to remember: this only works when you are in edit mode either in a list item or page.

An advanced example:


SharePoint 2013 version:

 (function ($) {  
   $.fn.SPEditable = function () {  
     return this.each(function () {  
       $(this).addClass("ms-rte-layoutszone-inner-editable ms-rtestate-write").attr("role", "textbox").attr("aria-haspopup", "true").attr("contentEditable", "true").attr("aria-autocomplete", "both").attr("aria-autocomplete", "both").attr("aria-multiline", "true");  
     });  
   };  
   $.fn.SPNonEditable = function () {  
     return this.each(function () {  
       $(this).removeClass("ms-rte-layoutszone-inner-editable ms-rtestate-write").removeAttr("role aria-haspopup contentEditable aria-autocomplete aria-multiline");  
     });  
   };  
 })(jQuery);   
 

Run Custom Function before "Save" Button is Clicked with PreSaveAction. SharePoint 2010

Add Javascript function to the page:

function PreSaveAction() 

    // your custom code goes here
    return true;  // OK to proceed with the save item }

For more information, check this post:
http://edinkapic.blogspot.ru/2007/10/add-javascript-date-validation-into.html

5 Jun 2013

Run C# Code from Powershell that uses SharePoint DLL's

Here is a very nice article
http://blogs.technet.com/b/stefan_gossner/archive/2010/05/07/using-csharp-c-code-in-powershell-scripts.aspx

For example:

Code:
$Assem = ( 

"Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" , 

"Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 

) 


$Source = @" 

using Microsoft.SharePoint.Publishing.Administration; 

using System; 


namespace StefanG.Tools 

{ 

public static class CDRemoteTimeout 

{ 

public static void Get() 

{ 

ContentDeploymentConfiguration cdconfig = ContentDeploymentConfiguration.GetInstance(); 

Console.WriteLine("Remote Timeout: "+cdconfig.RemoteTimeout); 

} 


public static void Set(int seconds) 

{ 

ContentDeploymentConfiguration cdconfig = ContentDeploymentConfiguration.GetInstance(); 

cdconfig.RemoteTimeout = seconds;

cdconfig.Update();

} 

} 

} 

"@ 


Add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharp 


[StefanG.Tools.CDRemoteTimeout]::Get()


[StefanG.Tools.CDRemoteTimeout]::Set(600)


4 Jun 2013

SharePoint 2010. Open 'Browse' Ribbon Tab by Default

Just include InitialTabID=Ribbon.Read in your URL parameter:
 http://site/List1/Forms/DispForm.aspx/&InitialTabID=Ribbon.Read