Search code examples
sharepointsharepoint-2010quicklaunchcewp

Customize the quick launch items for certain pages in sharepoint


I have requirement where client wants to customize the items in quick launch for only certain pages.So, I want to change the items in the quick launch with some other items for a few pages.(Not about cahnging the style of quick launch. Its about the replacingthe content in quick launch)

I hope using CEWP, I can achive this.But I am not much aware how to do it.


Solution

  • I had followed following steps to achive the goal

    1.. Added a CEWP in the page

    1. Created a text file with Following script and added it to shared dcouments
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
     <script type="text/javascript">
      function startClock(){
    
        var div= document.getElementById('s4-leftpanel-content');
    
       var spans= div.getElementsByTagName('span');
    
     for (index = spans.length - 1; index >= 0; index--) {
     spans[index].parentNode.removeChild(spans[index]);
    
     }
    
     var urls= div.getElementsByTagName('a');  
     for (index = urls.length - 1; index >= 0; index--) {
      urls[index].parentNode.removeChild(urls[index]);
     }
    
      var pTag = document.createElement('p');
     pTag.innerHTML = "HR Report";
        div.appendChild(pTag);
    
       var aTag = document.createElement('ul');
       div.appendChild(aTag);
    
      var newLi = document.createElement('li');
       aTag.appendChild(newLi);
    
       var a= document.createElement('a');
        a.setAttribute('href',"url");
        a.innerHTML = "report2";
       newLi.appendChild(a);
    
    //do onload work
      }
       if(window.addEventListener){
       window.addEventListener('load',startClock,false); //W3C
        }
        else{
     window.attachEvent('onload',startClock); //IE
    }
    </script>
    

    enter code here

    1. Paste the url text file in shared documents in CEWP as content link(Edit web part >>content link>>paste url)

    Now, existing items in the Quick Launch is removed and new items are added