Thursday, 15 May 2014


<xsl:value-of select="ddwrt:FormatDateTime(string(ddwrt:Today()),1033,'dd')"/>

Displaying today’s date using XSL and SharePoint
 < xsl:value-of select="ddwrt:Today()">

FormatDate(string szDate, long lcid, long formatFlag) 
FormatDate(@Today, 1033, @No)

1  : 5/9/2007
3  : Wednesday, May 09, 2007
4  : 9:06 AM
5  : 5/9/2007 9:06 AM
7  : Wednesday, May 09, 2007 9:06 AM
12: 9:06:12 AM
13: 5/9/2007 9:06:12 AM
15: Wednesday, May 09, 2007 9:06:12 AM

 < xsl:value-of select="ddwrt:FormatDateTime(string(ddwrt:Today()), 1033,'yyyyMMdd')" > < /xsl:value-of > 

XsltListViewWebPart Date Format using DDWRT
 <xsl:value-of select="ddwrt:FormatDateTime(string(@Modified), 3081, ‘dd-MMM-yyyy’)" />

SPLocale.LCID property & Regional settings (SharePoint Server 2010)
 Australia: 3081
 Persian: 1065

Branding CSS and Javascript tricks

How To: Hide Left Side Navigation on Home Page
<style type="text/css">
 body #s4-leftpanel {display: none;
.s4-ca {margin-left: 0px;

How To: Hide Recently Modified
<style type="text/css">
 .s4-recentchanges {display:none;}

How To: Change the “No Items” message in a discussion web part with jQuery
<script type="text/javascript">
 $("td .ms-vb:contains('There are no items to show in')").text('There are no active discussions');

How To: Hiding “Add new item” and “There are no items to show…” in SharePoint

How To: How To Remove Extra Space Around the Web Part In SharePoint 2013
<style type="text/css">
 .ms-webpartPage-root {border-spacing: 0px !important;}
 .ms-webpartzone-cell {margin: 0px !important;}

How To: Hide a web part with zero rows
function HideWebPartWithZeroRows()
  var a = document.getElementsByTagName("TABLE")
  for (var i=0;i<a.length;i++)
    if (a[i].summary=="Test List")
      if (a[i].rows.length==1)
        //hide all but the title bar
        //var x =  a[i].parentNode.parentNode.parentNode.parentNode.parentNode
        //hide the entire web part
        var x =  a[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode"none";

How To: Remove link border from around image
   a img {border:none}
<a href="">
   <img src="">

OR via inline styles:

<a href="">
   <img src="" style="border:none;">


Monday, 10 March 2014

SharePoint 2010 on Windows Server 2012

When you try and run the SharePoint 2010 prerequisite on Windows Server 2012 R2, you will receive an error and it fails right away.

To get around the issue, Run PowerShell and execute this command:
Get-WindowsFeature | Where-Object {$ -like "*net*" }

If the above doesn't work for you, type Import-module servermanager to add the Get-WindowsFeature cmdlet.

The above command is to see which .NET features were installed. 3.5 is not installed and that might be our missing link:

To add it, you’ll need your Windows 2012 R2 source media. Assuming your media is in your D: drive, the command to add it would look like this:
Add-WindowsFeature Web-Asp-Net -Source D:\sources\sxs

If you have an .iso file, mount it to a drive and then replace the "D:\" with your own drive letter.

After executing the command, wait for few minutes until the new command line shows (as bellow) this will add the stuff that the SharePoint prerequisite installer wants.

Now if we run the perquisite again, it runs successfully and we can move on to install SharePoint.

Note: in my case, I had to restart windows first before continue the installation.

Sunday, 23 February 2014

Thursday, 20 February 2014

How to Change an Image's Size and Shape in SharePoint


Scenario: I see it all the time: SharePoint content owners create sites using images that are much too large for Web consumption. It’s easy to understand why this happens. Sally Site-Owner gets a photo or image from the marketing department that was created for print or some other high-resolution format. Sally uploads the image to SharePoint and simply resizes its height and width using the ribbon controls to make the page look nice. Of course, resizing an image in this way doesn’t actually make the file size any smaller, and now end users (potentially even users on slow or metered mobile connections) will have to patiently download the large image to see the page.

SharePoint 2013 answers this problem with a SharePoint Server publishing feature known as image renditions. With image renditions, you can add images to a library and easily add them to pages using various predetermined widths and heights without downloading the full-sized image.
I’ll assume the first two are pretty easy to figure out without me going through the steps. To turn on Blob Caching, simply navigate to the web.config file for your SharePoint site on the physical server. It is usually located in a directory similar to C:\inetpub\wwwroot\wss\VirtualDirectories\80. You can use IIS to help find the directory if you want. Open web.config in an editor like Notepad (when you hit Save, IIS will reset the SharePoint site, so make sure not to do this on production during peak hours) and use Control-F to find the first instance of “<BlobCache”. In this line, you will see enabled="false". Simply change this to “true” and hit save.

Now you can create your own image-rendition sizes fromSettings > Site settings > Look and Feel > Image Renditions. There should be a few predefined sizes you can use. To create your own, simply click Add new item, enter a name, width and height, then click Save. Now, when you add images to a picture library, you will have a rendition that matches that size that you can work with.
To work with the image renditions, navigate to your picture library and upload a picture. Once the picture thumbnail shows in the library, hover over it, click the ellipsis in the bottom-right, and then click Edit Renditions.

From here, you will see a list of all the renditions that are available, with images already created for each size. You can edit the sizing and cropping of a rendition from Click to change. This will show you a dashed box that is constrained to the size of the image rendition, and you can move and resize photo accordingly to show the image in the best possible way. This can be useful for showing faces or text in smaller sizes.
 With your image renditions set up and configured, now you can select from the different size options when you insert an image into a publishing page. After editing a page and inserting the image, from the ribbon you would just click the image tab and then choose from the Pick Rendition dropdown.
Because an image rendition is being used, the image in my example is actually a 150px by 150px file and should download quicker than a full-sized image. Pretty cool, right? What if you want to reference the image rendition directly using code or without the ribbon? Well that’s pretty easy: You can pass URL parameters to the image for either the RenditionID (the number in the image rendition list order: 1, 2, 3, etc.), or for width and/or height.

For example, in my sample to the right, the raw image URL inSharePoint was:
If I want to load the image rendition for 304x100, I can reference the image like this:

You can reference an image with just the height or width also, but if there are multiple matching renditions, the first will be returned.

Image rendition is a pretty handy feature for helping content authors create images that are sized appropriately for the Web. Oh hey, did I forget to mention that image renditions work with videos also? So be sure to try that out as well!​

Can’t crawl web apps you KNOW you should be able to crawl

To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:
  1. Set the
    registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
    281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
  2. Click Start, click Run, type regedit, and then click OK.
  3. In Registry Editor, locate and then click the following registry key:
  4. Right-click MSV1_0, point to New, and then click Multi-String Value.
  5. Type BackConnectionHostNames, and then press ENTER.
  6. Right-click BackConnectionHostNames, and then click Modify.
  7. In the Value data box, type the host name or the host names for the sites that are on the local computer, and then clickOK.
  8. Quit Registry Editor, and then restart the IISAdmin service.

SharePoint Trick: Link to an Image Thumbnail

  • Navigate to the image in the image library where it is stored.
  • Click on the image so that you see the "item view" of the image. The default attributes such as Name, Title, and Preview will show up, along with an attribute called Thumbnail Preview.
  • The link to the Thumbnail Preview is not easily exposed, but you can "cheat" and find it by right clicking on the image and then selecting Properties.
  • Select the entire contents of the Address (URL) field shown in the thumbnail image properties. Be sure to keep scrolling in the Address (URL) field until you have captured the complete URL for the thumbnail. You will know if you have it right if you see _jpg.jpg at the end.
  • You can then paste this "secret" URL in a hyperlink column in your list and the link will show the thumbnail, not the image preview.
You can also create the link to the Thumbnail on your own by inserting the characters _t/ in front of the file name and the characters _jpg immediately after the file name in the default image URL as shown below:
Link to default image preview:
  • intranet/sitename/libraryname/foldername/imagename.jpg
Link to Thumbnail for the same image:

  • intranet/sitename/libraryname/foldername/_t/imagename_jpg.jpg

SharePoint Governance: To get started, it’s important to have the right conversations!