Tag Archive | Customization

Slideshow using Content Search Webpart

Off late, I have been working on client side to provide seamless solutions on Online sites.One such requirement was to provide slideshow functionality for machine – mechanical drawings uploaded by the engineering team. Well, the solution seems to be straight – forward : to just use a picture library and configure the timelines.

Nevertheless, the business were desperate to see the title and last-modified date for these images displayed.My initial thought was to use jQuery and customize it accordingly. But , to my surprise this feature was supported by OOTB feature – Content Search Webpart, way to go !

I presume the reader has knowledge creating a new “Result Source” to query the images from the picture library. The query builder in result source has preview to show the query results .

The final step is to add a content search webpart and configure it with the settings below

Capture

Webpart settings

The change query property should now point to the result source created earlier, preview shows the results fetched for the current result source.

Capture

Change query

The end product would be something like below Capture

Retain workflow history

In the recent times , I was involved in a migration from MOSS to SP 2013 which involved lot of challenges and learning.Between, one such important activity I would like to share is to retain the workflow history of an item when it is acted upon by the approvers.

The workflow history for an item exist only for a mere 60 days , however it is crucial for business to keep track / audit of the item whose outcome could be either approved or rejected.It becomes a challenge for a developer to tweak this OOTB feature in SharePoint.After spending lot of time investigating we came up with a strategy:

Athough the history is wiped out for an item in the list, the data do still exist in the workflow history list that is hidden by design in SharePoint.

~SiteUrl/lists/Workflow%20History/

The link will take the user to the Workflow History list – a repository of all the history data.One of the ways to track history data of an item is to filter the list by Item based on their ID . This will fetch all the relevant data.

The equivalent URL is :

~SiteUrl/lists/Workflow%20History/Audit%20View.aspx?FilterField1=Item&FilterValue1=ID

Obviously, this does not serve the purpose for the end user as this is not a user friendly solution and I am sure that most the users may not be happy with this.

The workaround would be to add a calculated column to the list and pre-configure it with the URL mentoined above.This will generate a hyperlink for the user to navigate.However, to get a user friendly name it is advised to use something like :

=CONCATENATE(“~SiteUrl/lists/Workflow%20History/Audit%20View.aspx?FilterField1=Item&FilterValue1″,”=”,ID)

You could try the above steps and try for yourselves.

Hiding I Like it and Tag notes tags in Sharepoint 2010

I was customizing the master page in sharepoint 2010 and found out new tags and they were :

  • I Like it
  • Tags & notes

I had a requirement of hiding these tags in master page and hence, sharing the same in this blog.

  1. Open the site in IE 8.
  2. Press F12 to pop up the developer tools window.
  3. Arrow as shown below can be used to select any item in the page.
  4. This shows the section I like it and Tag & notes chosen.The tool shows the related HTML ,Scripts and styles with respect to the item.
  5. Now hide the section with styles using the tool editor as shown
  6. This tool however doesn’t make changes to the page, just gives us a preview of what has to be done.It is a nice tool that helps us in locating the items, classes and sneak peek at the changes.
  7. To make actual changes go to V4.Master and add the jQuery code to hide this . Register jQuery library in master pages before carrying out this operation .
  8. Now you can see that this section is disabled in the page.

Customise the navigation in Sharepoint

We can customise the navigaiton in a sharepoint site using the WSS V 3.O navigation store , that is represented by the namespace Microsoft.Sharepoint.Navigation .
It provides classes ,properties and methods to customise the navigation of a sharepoint site .
lets see how to add a custom link to a quick launch bar /top navigation bar on activating a feature
class CustomLinkQuickLaunch : SPFeatureReceiver
{

//Get the context of the current site
SPSite oSite = SPContext.Current.Site;
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{

using(SPWeb oWeb = oSite.OpenWeb())

{
//Get the tree view colllection of nodes in the quick launch bar
SPNavigationNodeCollection nodeColl=oWeb.Navigation.QuickLaunch;

//Get the tree view colllection of nodes in the top navigation bar
SPNavigationNodeCollection nodeColl=
oWeb.Navigation.TopNavigationBar;
//Add a new node to the collection giving it a titel and url , boolean value indicates whether the link is outside the current site coll or not .Since ,it is outside the current site coll we pass boolean true here
SPNavigationNode oCentralAdminNode =

new SPNavigationNode(“Central Admin Home “, “url of the central admin”,true);
nodeColl.AddAsLast(oCentralAdminNode);

//Now we can add a child node to the central admin link in a simialr fashion
SPNavigationNode oExtNode = new SPNavigationNode(“Yahoo Home “, “http://www.yahoo.com/”, true);
oCentralAdminNode.Children.AddAsFirst(oExtNode);
oWeb.AllowUnsafeUpdates = true;
oWeb.Update();

}
}
We need to delete the node from the quick launch bar/top navigation bar on feature deactivation , it will create a duplicates entry of the nodes when activated for the next time otherwise .The following code does exactly this

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
using(SPWeb oWeb = oSite.OpenWeb())

{
//Get the node collection of the quick launch or top navigation bar
SPNavigationNodeCollection nodeColl=oWeb.Navigation.QuickLaunch;
SPNavigationNodeCollection oNodeColl = oWeb.Navigation.TopNavigationBar;
oNodeColl.Delete(indexing to the node collection can be done to get a node to be deleted)

oWeb.AllowUnsafeUpdates = true;
oWeb.Update();

}
}
}

Creating Custom List form

We know that a list or library consists of pages like Newform.aspx, DispForm.aspx, EditForm.aspx and so-on. In some cases,we may need to create our own Custom pages for Lists.There are two ways of doing this.

One way is to create a new page and associate the page with the list.Another way, is to modifying the existing pages using Sharepoint Designer which is the topic of discussion.

Steps Includes :

1.Go to the list/lib for which you need to create custom page(In our case Announcement list) and open the page to be modified(DispForm.aspx in this case) .You will see something like this.

2.Now,navigate to the web part zone of the list form web part and make it invisible.

The idea here is to make it invisible and add the customized list details.

3.Now, go to Insert Menu > Sharepoint Controls to add the Custom List form ,when you will be prompted with dailog box like this :

Here, choose the List/lib that you are customizing and the type of form to create (in our case it is Display Item form) and make sure to include standard toolbar as well.

4.Now,we have new List form that is ready to get customized.Lets take a scenario where we need to hide some fields like Contact Details while displaying details of a customer.

5.To hide a row (lets say expiray date in announcement list) select the row and modify the definition for the row :

It can be seen that i have modified the styles ,where i’m setting visiblity properties for that row as false.Save the page once it is done.

5.Now open the page in the site.It can be seem that our changes have been reflected in the page(cannot see the Expire row in the page).

We can use this approachto modify any of the existing list/lib pages and customize it accordingly.

Hiding Menu Bar in Web Part

I was wondering how to remove the properties menu for a web part , once it is deployed in a sharepoint Site, so that it can’t be personalized for any user ( not even by the administrator of that site) .

Later, i found a work around for this..which happens to be relatively simple than what i thought could be.

Open the page using Sharepoint designer ,navigate to the web part zone and add the enclosed code in the web part zone

PartChromeType=”None” AllowLayoutChange=”false” MinimizeVerb-Enabled=”false” MinimizeVerb-Visible=”false” AllowPersonalization=”false”

Now,save the changes and verify the same in the site.