Pages

Subscribe:

Thursday, December 20, 2012

SharePoint 2010 Navigation: Quick launch and Navigation


In this article I will show the Quick Launch in Team site and the Publishing site .
If you navigate to the site settings the “Look and Feel” section you will see that there are different options available between collaboration and publishing sites.
Look and feel options of a publishing site

Look and feel options of a collaboration site

In collaboration sites there is a link named “Quick launch” and on publishing sites there a link named “Navigation”.
The “Quick launch” configuration in collaboration sites is straight forward; you can add headings and links and modify the order.

Now let’s have a look at the navigation option on publishing sites.

First of all, it looks totally different but we have a lot more options here. We can inherit navigation from above and we can configure both the global and the current navigation.
If you want to open links in a new window, check the Open link in new window under URL


If the collaboration site is a sub site of a publishing site it inherits the configuration tool from above and offers the same tool like the publishing site. If we want to make the publishing navigation features available in a collaboration site collection, we have to activate the publishing infrastructure feature on the site collection.

Wednesday, December 19, 2012

Highlight the Search Keyword in SharePoint 2010 results page

Branding the SharePoint Search page or Highlighting the Search Keyword in SharePoint 2010.

To Highlight the Search keyword in search result page in SharePoint 2010 add the css to the master page or in the Content Editor Web Part a.k.a CEWP.

Open the Search Result Page in Edit Mode, Add CEWP to the Search Result Page. In CEWP, Edit HTML source add the css.

<style>
.srch-Title2 A STRONG {
BACKGROUND-COLOR: yellow; color:black;
}​​
</style>
<style>
.srch-Description2 STRONG {
BACKGROUND-COLOR: yellow; color:black;
}​​
</style>​​​

After adding the css, save the page. 

If you enter any keyword in SharePoint Search it will display the result page as 


Happy Coding..!!!

Reference Link: https://www.nothingbutsharepoint.com/sites/eusp/Pages/Brand-SharePoint-Search-Results-What-you-thought-you-were-staying-vanilla.aspx


Monday, November 26, 2012

SPDisplayRelatedInfo in SP 2010 JQuery


<script type="text/javascript">
$(document).ready(function(){
        //Gets the values from the Related List
         $().SPServices.SPDisplayRelatedInfo({
         columnName"Project",
         relatedList"Projects",
         relatedListColumn"Title",
         relatedColumns:["End_x0020_Date","Comments"],
         displayFormat"list",//shows the values in List,
         headerCSSClass"ms-hidden",// this is to hide the list 
        rowCSSClass:"ms-hidden",// this is to hide the list
        completefuncSetFields
        });
});

function SetFields(){
            var srcDivId = "SPDisplayRelatedInfo_Project ";
            var tds = document.getElementById(srcDivId).getElementsByTagName("td");
           
            if(tds.length>0)
            {
             var Column1Data1 = tds[0].innerHTML;
             var Column1Data2 = tds[1].innerHTML;
            
            $('#ctl00_m_g_8b1ecbc0_8438_4069_92d0_34cc9235ab90_ctl00_ctl05_ctl05_ctl00_ctl00_ctl04_ctl00_ctl00_TextField')[0].value = Column1Data1;
$('#ctl00_m_g_8b1ecbc0_8438_4069_92d0_34cc9235ab90_ctl00_ctl05_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_TextField')[0].value = Column1Data2;
      
}
}

Populate the fields based on Drop Down selection in NewForm.aspx using JQuery


Before doing that add the JQuery.js and SPServices.js reference in the Master Page. 

Then add the following script in the NewForm.aspx of the List 

<script type="text/javascript">
$(document).ready(function(){
        
         $().SPServices.SPDisplayRelatedInfo({
         columnName: "Project",
         relatedList: "Projects",
         relatedListColumn: "Title",
         relatedColumns: ["Client_x0020_Description","End_x0020_Date","ProjComments","Resources","Start_x0020_Date","Due_x0020_Date","Title"],
         displayFormat: "list",
         headerCSSClass: "ms-hidden",
        rowCSSClass:"ms-hidden",
        completefunc: SetFields
        });
});

function SetFields(){  
        
//Get the IDs of the fields to which you want to set the values
            var txtDescription = document.getElementById('ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField');
            var txtComment = document.getElementById('ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl12_ctl00_ctl00_ctl04_ctl00_ctl00_TextField');
            var txtAssignedTo= document.getElementById('ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_UserField_downlevelTextBox');
         var txtEndDate = document.getElementById('ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl11_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate');
         var txtStartDate=document.getElementById('ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate');
         var txtDueDate=document.getElementById('ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl09_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate');
         var txtTitle=document.getElementById('ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField');
           
         $("div#SPDisplayRelatedInfo_Project td").each(function(index){
         debugger;
         switch(index)
         {
             case 0:
             var desc = $(this).html();
     //This is for the Multiline Rich Textbox in IE  $('#ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_iframe').contents().find('body').text(desc);
         //This is for other browsers
             txtDescription.value = desc;
             break
            
             case 1:            
             var columnDate =$(this).html();
             var endDate = $.format.date(columnDate , "MM/dd/yyyy");            
            txtEndDate.value = endDate ;
            break;
            
             case 2:
             var comment = $(this).html();
         $('#ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl12_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_iframe').contents().find('body').text(comment);
             txtComment.value = comment;
             break;
            
             case 3:
             var resource= "";
             $(this).find('a').each(function(){
                 resource = $(this).html()+ ";" + resource ;
                 txtAssignedTo.value = resource;
             $('#ctl00_m_g_ff38e82a_f0dd_4c96_bd29_92038b50b4fb_ctl00_ctl04_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_UserField_upLevelDiv').text(resource);                                    
             });
             break
            
                case 4:             
             var columnDate1 =$(this).html();                               
             var startdate = $.format.date(columnDate1, "MM/dd/yyyy");                          
            txtStartDate.value = startdate;
            break;
           
                case 5:             
             var columnDate2 =$(this).html();
             var Duedate = $.format.date(columnDate2 , "MM/dd/yyyy");       
        
            txtDueDate.value = Duedate;
            break;
           
                case 6:
                var titleval= $(this).html();
                txtTitle.value=titleval;
                break;        
         }          
     });
 };       

</script>

Thursday, November 22, 2012

Script to Disable the Fields in NewForm EditForm in SharePoint


Before adding the following script to the NewForm or EditForm we have to give the Reference of jQuery.js and SPServices.js either in Master Page or in the form where you what to add this script.

<script language="javascript" type="text/javascript">

  $(document).ready(function() {
 
      var isUserOnly = false; //User group member only     
      var isAdmin=false;
      var groupName = "Admin Group";
 
   $().SPServices({

      operation: "GetGroupCollectionFromUser",

      userLoginName: $().SPServices.SPGetCurrentUser(),

      async: false,

      completefunc: function(xData, Status)
     
        {
        if($(xData.responseXML).find("Group[Name= Admin Group ']").length == 1)
            {
                isAdmin = true;            
            }
            else
            {
                isUserOnly=true;               
            }
          }
       });
      
       if (isUserOnly)
       { 
            //Disable DropDown
            $("Select[Title='Project']").attr("disabled", "disabled");             
           
           
            var Title =document.getElementById('ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField');

Title.disabled=true;

           
var assignedTo = document.getElementById('ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_UserField_downlevelTextBox');

assignedTo.disabled=true;

var assignedTodiv = document.getElementById('ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_UserField_upLevelDiv');  

assignedTodiv.disabled=true;

var description = document.getElementById('ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField');

description.disabled= true;

var description1  = document.getElementById('ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_iframe');

var StartDate = document.getElementById('ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate');
StartDate.disabled=true;
       
//Disable Calendar Image                   
var imgStartDate = document.getElementById('ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDateDatePickerImage');
imgStartDate.disabled=true;
       
                   
//MultiLine Rich Textbox
description1.disabled = 'disabled';
           
                       
//Disable Dropdown fields
DisableField("Project");
               
//Disable Multiline box     $('#ctl00_m_g_e8d7e5d3_7fc5_4496_b8b6_00a6a4f46062_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_iframe').contents().find('body').attr('disabled','disabled');

//PeoplePicker
$('nobr:contains("Assigned To")').closest("td").next("td").attr("disabled", "disabled");
$("div[id$='_UserField_upLevelDiv']").attr("contentEditable",false);
$("span[id$='_UserField']").find("img").hide();        
           
       }   
 }); 


//Function to Disable DropDown
 function DisableField(title)
{
    for(var i = 0; i < document.all.length; i++)
    {
        var el = document.all[i];
        // find html element with specified title
        if(el.title == title)
        {
            el.disabled = true; // disable

            // if the next element has a reference to the current element
            // then disable if as well
            if(i < document.all.length - 1)
            {
                var el2 = document.all[i + 1];
                if(el2.outerHTML.indexOf(el.id) > 0)
                {
                    el2.disabled = true;
                }
            }
            break;
        }
    }
}

</script>