Changing SharePoint 2010 search box icon using CSS

There are a few ways to change the search box icon like specifying image URL by creating or using existing delegate control and another way to change it on runtime using JavaScript but there is another simpler way so let’s explore it and look at the html for icon which is being generated by the SmallSearchInputBox html control

<a href="javascript:S3031AEBB_Submit()" title="Search" id="ctl00_PlaceHolderSearchArea_ctl01_S3031AEBB_go">
<img style="border-width:0px;" src="/_layouts/images/gosearch15.png" alt="Search" class="srch-gosearchimg" onmouseout="this.src='\u002f_layouts\u002fimages\u002fgosearch15.png'" onmouseover="this.src='\u002f_layouts\u002fimages\u002fgosearchhover15.png'" title="Search">
</a>

We can see that there is an inline img tag inside an anchor tag so if we set the img tag display’s to none and specify background image for the anchor we can easily change icon so let’s try this out. To apply the following CSS, we’ll have to create a CSS in Style Library in which we’ll override default styling and specify it as an alternate CSS in Master page site settings.

td.ms-sbgo
{
padding:0px 3px 0px 3px;
}

td.ms-sbgo a
{
    background-image: url(/Style%20Library/Images/our_search_button.png);
    background-repeat: no-repeat;
    background-position: top left;
    display:block;
    width:20px;
    height:19px;
}

td.ms-sbgo a img
{
    display: none;
}

How to add or remove languages from Advance Search Page in SharePoint 2010

Changing the language list on Advance search page is very simple, just follow these steps.

Step 1: Go to Advance page, site actions and then edit page.

Step 2: Now edit advance search box web part and collapse properties section.

Step 3: Copy xml from properties textbox and paste it in any xml editor like Visual Studio so we can modify it easily

Step 4: Search for languages tag and remove any language that is not necessary from the list. For example let’s remove all languages except English from the list, now it should look like

<Languages>
<Language LangRef="en" />
</Languages>

Step 5: To add another language, just add another Language element with LangRef attribute. Values for LangRef attribute will LangID from the LangDefs element. For example if we want to add Arabic then our Languages element would look like

<Languages>
<Language LangRef="en"/>
<Language LangRef="ar"/>
</Languages>

Step 6: Copy the entire xml and paste it in properties textbox in advance search box web parts (Where we initially copied the xml from) and save the page.

That’s it we are done.

I hope you find this post useful. Thanks

How to add global navigation in SharePoint 2010 Fast or Enterprise Search Center Sites

This post describes how we can add global navigation in SharePoint 2010 Search Center sites.

Search center sites use minimal master page which doesn’t include global navigation controls. Even if we change site’s master page (To change master page, publishing feature has to be activated) from minimal to v4 or nightandday global navigation will not appear and we’ll see some strange results like search textbox going behind the ribbon. The reason for this is that the controls which render global navigation are not in minimal master page, they are in page layouts. So let’s start our short journey.

Step 1: Open root site in SharePoint Designer, go to All Files, _catalogs and then masterpage

Step 2: We’ve to change SearchMain.aspx (default page containing search text box), SearchResults.aspx (which shows search results) and AdvanceSearchLayout.aspx (which has advance search controls) respectively

Step 3: Let’s start with SearchMain.aspx, click this file, edit it and then click Advance mode button at the top so we can do the desired changes.

Step 4: Search for srch-sb-main, we’ve to paste the following code which renders the global navigation before div with class srch-sb-main

<div class="s4-lp s4-toplinks" style="background-image:url(/_layouts/images/selbg.png); background-repeat:no-repeat;
repeat-x:left top; background-color:#f6f6f6; vertical-align:middle; min-height:25px; border-top:1px solid #e0e0e0;
border-bottom:1px solid #b8babd">

<SharePoint:AspMenu
ID="TopNavigationMenuV4"
Runat="server"
EnableViewState="false"
DataSourceID="topSiteMap"
AccessKey="<%$Resources:wss,navigation_accesskey%>"
UseSimpleRendering="true"
UseSeparateCss="false"
Orientation="Horizontal"
StaticDisplayLevels="2"
MaximumDynamicDisplayLevels="1"
SkipLinkText=""
CssClass="s4-tn"/>

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
<Template_Controls>

<asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="SPNavigationProvider"
id="topSiteMap"
runat="server"
StartingNodeUrl="sid:1002"/>

</Template_Controls>
</SharePoint:DelegateControl>

</div>

Step 5: Let’s save our page and view it in browser.

Step 6: Okay we got our global navigation on search page, now let’s add it in search results page. So let’s edit SearchResults.aspx in advance mode

Step 7: Search for srch-sb-results, we’ve to paste the code from step 4 which renders the global navigation before div with class srch-sb-results

Step 8: Search for PlaceHolderMain, we’ve to paste the code from Step 4 which renders the global navigation inside the content place holder with id PlaceHolderMain

SharePoint 2007 workflows missing after migrating to SharePoint 2010

After migrating SharePoint 2007 portal to 2010, I noticed that the workflows associated with lists were not available and after researching a bit, I found something interesting on TechNet.

If you had disabled the Workflow Auto Cleanup timer job in your Office SharePoint Server 2007 environment, make sure that you disable this timer job in your new environment also. If this timer job is enabled in the new environment and disabled in the previous version environment, you might lose workflow associations when you upgrade. For more information about this timer job, see Disable preservation of workflow history (SharePoint Server 2010).

I checked the timer job and it was running on both machines so something else was at play here so later I found out here that

“In SharePoint 2010 the 2007 workflows are there to allow any running workflows to complete, but by default creating new instances of the workflows is disabled as the expectations are that you will want to move forward to the SharePoint 2010 workflows.”

And to allow creation of SharePoint 2007 workflows instances, I followed Vinit’s solution which was

  1. Activate SharePoint 2007 workflows feature in Site Collection Features
  2. Remove ‘none’ from <AssociationCategories>none</AssociationCategories>

    14\template\features\ReviewWorkflows\Reviewapproval.xml

    14\template\features\ReviewWorkflows\ReviewFeedback.xml

    14\template\features\SignatureWorkflow\Signatures.xml

Don’t’ forget take backup of these files before modifying them.

I hope you find this post useful, thanks for reading.

How to create multilingual user experience in SharePoint 2010

This post describes how we can create multilingual user experience in SharePoint 2010. Let’s say we’ve a site named “HR” and under that site we’ve a document library called “Leave Requests”.

Let’s assume we’ve both English and Arabic users we’ve been asked to give them interface in their respective languages, creating variations for site and creating two separate lists is an option but then we’ll have to manage two lists and deal with them separately and most importantly variation only works with Publishing sites. Now there is another option and a better one for this type of scenarios which is Multi-lingual user interface (MUI).

MUI simply allows us to select a display language so after we configure it, users can just simply change their display language and all out-of-the-box stuff will be displayed in the respective language and we can also very easily translate custom columns, menus and stuff. From a developer’s point of view it is same as localizing content in Asp .NET using resource files but this time we don’t have to create them (More benefits of multilingual user interface).

Okay enough talking let’s see this in action.

Step 1: Download and install the desired language pack

Step 2: Rerun the SharePoint Product and Technologies configuration wizard

Step 3: Now let’s go to HR site settings

Step 4: Let’s go in to Language settings under Site Administration

SharePoint 2010 Site Administration

Step 5: Select Arabic and click ok

SharePoint 2010 Language Settings

Step 6: Now we should be able to see Select Display Language in User Settings menu.

SharePoint 2010 Display Language

Step 7: Let’s go to Leave Request library in our HR site and select Arabic and see what happens

SharePoint 2010 Arabic MUI View

Step 8: Okay now we can the interface is in Arabic, let’s relax for a while but wait the list title “Leave Requests” is still in English as well the title of default view “All Documents”, we can easily change them. Let’s go to Library setting and then General settings and replace the English title with its Arabic counterpart.

SharePoint 2010 Editing List name MUI

Step 9: Now we can see the list name is appearing in Arabic and we’ll go in English we can see it’s the English one because SharePoint keep them in resource files, we can also change view name, menus, quick launch and custom column names like this as well. (More details on what’s supported and what’s not on)

Step 10: Now changing titles and other stuff might be cumbersome if we keep going in to settings just to change title and to avoid this we can export translation which will give us the resource file, we can very easily edit it using Visual Studio or any other xml editor and translate our content and then upload it again by importing translations. Let’s go to Site settings and then Language settings to export translation.

SharePoint 2010 Site Administration Export Translations

Step 11: Let’s select Arabic and export, afterwards we’ll get a prompt to save resource file for our site, we can then edit it and upload it back.

SharePoint 2010 Exporting Translation for MUI

That’s all for now my friends, thanks for reading. I hope you find this post useful.

SharePoint 2010 opening PDF in browser

After migrating from SharePoint 2007 to SharePoint 2010, users complained that they whenever they click on PDF they are seeing save as dialog whereas they could open PDFs directly browser in SharePoint 2007. I found out that there is an option for browser file handling in Central Administration, Web Application General Settings and Browser File Handling which was set to Strict, it add headers to force the browser to download file, setting it to Permissive allowed the users to view PDF directly in browser again.

Following are some useful resources on tech net for more details

Configure settings for a Web application (SharePoint Server 2010)

SharePoint 2010 Browser File Handling Deep Dive

10 easy steps to create an elegant jQuery slide show in SharePoint 2007 using Content Query Web Part

Recently I’d a requirement to create a slideshow in SharePoint 2007 and content query web part is great for these types of scenarios where a list has to be query and list items are to be rendered with some HTML. There are a lot of great jQuery plugins available for slideshow, we’ll be using jQuery.Popeye. You can use the following steps to use any other plugin if you like, okay so let’s get started.

  1. Download jQuery and jQuery.Popeye plugin
  2. Go to Style Library, open with explorer and paste jQuery.Popeye folder from the downloaded archive along with jquery-1.8.1.min.js
  3. Create a Picture Library and upload images that you’d like to be displayed in Slide Show.
  4. We’ve to create a new XSL template which will generated the necessary HTML for slide show so open the site in SharePoint Designer and then navigate to All Files, Style Library, XSL Style Sheets, make copy of ItemStyle.xsl and then edit ItemStyle.xsl
  5. Go to bottom of the file and paste the following XSL before </xsl:stylesheet>

    <xsl:template name="PopeyeSlideShow" match="Row[@Style='PopeyeSlideShow']" mode="itemstyle">
    <xsl:variable name="DisplayTitle">
    <xsl:call-template name="OuterTemplate.GetTitle">
    <xsl:with-param name="Title" select="@Title"/>
    <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
    </xsl:call-template>
    </xsl:variable>

    <xsl:variable name="SafeLinkUrl">
    <xsl:call-template name="OuterTemplate.GetSafeLink">
    <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
    </xsl:call-template>
    </xsl:variable>

    <xsl:variable name="Header">
    <xsl:if test="count(preceding-sibling::*)=0">
    <![CDATA[
    <div id="ppy1">
    <ul>
    ]]>
    </xsl:if>
    </xsl:variable>

    <xsl:variable name="Footer">
    <xsl:if test="count(following-sibling::*)=0">
    <![CDATA[
    </ul>
    <div>
    <div>
    <!--<div>
    <strong></strong>
    </div>-->
    </div>
    <div>
    <a title="Previous image">Previous Image</a>
    <a title="Enlarge">Enlarge</a>
    <a title="Close">Close</a>
    <a title="Next image">Next Image</a>
    </div>
    </div>
    </div>
    ]]>
    </xsl:if>
    </xsl:variable>

    <xsl:value-of select="$Header" disable-output-escaping="yes" />
    <li>
    <a>
    <xsl:attribute name="href">
    <xsl:value-of select="$SafeLinkUrl"></xsl:value-of>
    </xsl:attribute>
    <img>
    <xsl:attribute name="src">
    <xsl:value-of select="$SafeLinkUrl"></xsl:value-of>
    </xsl:attribute>
    </img>
    </a>
    </li>
    <xsl:value-of select="$Footer" disable-output-escaping="yes" />
    </xsl:template>

  6. Create a new page, drop content query web part, edit web part, collapse query section, select show items from following list and select the library you created in Step 4, also select picture library as List Type.
  7. Collapse presentation section and select PopeyeSlideShow as ItemStyle so that the HTML we wrote while creating XSL template in step 5 is applied while rendering images returned.
  8. Now all that’s missing is to include CSS for this plugin along with including references to JavaScripts and then finally calling the plugin so let’s add this now.
  9. Now again open SharePoint Designer, go to All Files, Style library and create a new js file, name it jquery.popeye.loader.js, edit it and paste the following

    <link type="text/css" rel="stylesheet" href="/Style%20Library/jQuery.popeye/css/popeye/jquery.popeye.css" media="screen" >
    <link type="text/css" rel="stylesheet" href="/Style%20Library/jQuery.popeye/css/popeye/jquery.popeye.style.css" media="screen" >
    <script src="/Style%20Library/jquery-1.7.2.min.js"></script>
    <script src="/Style%20Library/jQuery.popeye/lib/popeye/jquery.popeye-2.1.min.js"></script>
    <script type="text/javascript">
    <!--
    $(function(){
    $("#ppy1").popeye({
    autoslide:true
    });
    });
    //-->
    </script>
  10. Now edit the page which we created in step 6 and drop content editor web part so we can include jquery.popeye.loader.js. Modify the shared web part and enter /Style%20Library/jquery.popeye.loader.js in the content link box, test the link and then click ok

Now you should have something like the following image.

Creating a jquery slideshow in SharePoint_2007 using Content Query Web Part

Hope you find this post useful, thanks for reading.