locked
Show specific Document library on site hierarchy view Quick launch Navigation of site collection. RRS feed

  • Question

  • Hi ,

    I had a site collection with sub-sites underneath it. All sub-sites including Main site collection have a Document Library called “Documents”. I need to show up the tree view with sub-sites and only “Documents” Library on the Main Page Quick launch Navigation of Site Collection. So user can go directly to that library from default site collection page. I had write this code and i can only get Main site collection Document library but not the sub-sites  Document Library. I am not a Jquery expert i need some help to complete this code.

    I had this jQuery :

    <script type="text/javascript" language="javascript">
    $(document).ready(function()
    {
        // hide all of the tree view elements that are not related to the 'Documents'
        $("div.quicklaunch-treeview > div > table").each(function() {
            if( $(this).find("td.ms-navitem > a:not(:contains('Documents'))").is("a") ) {
                   $(this).css("display","none")
            }
        });         
        
    });
    </script>
    Aniket
    Friday, October 28, 2011 12:10 AM

All replies

  • Hi Aniket,

    there is an OOTB way to achieve this,

    On top level site go to Site Action > Site Settings > Navigation under look & Feel

    It will show you Global Navigation and Current Navigation

    You can modify your required change in current navigation and add only Sub Sites > Documents.

    Hope this helps


    Warm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/ | Posting is provided "AS IS" with no warranties, and confers no rights
    Friday, October 28, 2011 10:28 PM
  • Hi Pratik,

     

    With the settings you suggested i can only do on top level site doc library  not sub-sites doc library .

     


    Aniket
    Sunday, October 30, 2011 10:47 PM
  • Hi Aniket,

    Elements of subsites can’t show in Main Page Quick launch Navigation of Site Collection, they only can show in Tree View. So you can enable Tree view in Site Settings, and then add the code bellow in MasterPage.

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

     $(document).ready(function()

     {

         // hide all of the tree view elements that are not related to the 'Documents'

         $("td.ms-navitem > a:not(:contains('Form'))").each(function() {                   

                 if($(this).attr('href').indexOf('ListNode')!=-1) {

                            if($(this).is("a")) {

                                        $(this).parent().parent().css("display","none");

                             }

                 }                                             

         });          

     });

     </script>

     

    Hope this help.

    Thanks, 
    Emir

    Tuesday, November 1, 2011 1:50 AM
  • Hi Emir,

    Thanks very much for the above script. 

    I need to show only one document library called Documents on all sites and sub-sites under tree view of the Main root site.

    Your script can see the Documents document library of the Main root site but the issue remains same for the sub sites. is there any way to get only Documents document Library of the sub sites too.

     

    Regards,


    Aniket
    Tuesday, November 1, 2011 6:21 AM