2

Good morning,

I'm using sharepoint online part of Office 365, but my license is business essential. I need to display inside a page all the sub sites of my site collection with -Title - Link - Logo Image. I can do it neither with content query nor content search Web part because of my licence. Could someone please help me to solve this problem using javascript with script web part. Thank you

1 Answer 1

2
  1. Create a SharePoint Add-in project
  2. Select Client Web Part
  3. Paste this code below in your App.js :

    function getWebs()
    {
       var context = SP.ClientContext.get_current();
       var web = context.get_web();
       var site = context.get_site(); 
       var rootWeb = web.get_rootWeb();
       var subWebs = rootWeb.get_webs();
    
       context.load(subWebs, 'Include(Title, ServerRelativeUrl,ParentWeb,Url)');
       context.executeQueryAsync(
        function () {  
             for (var i = 0; i < subWebs.get_count(); i++) {
                var subWeb = subWebs.getItemAtIndex(i);
                var parentWeb = subWeb.get_parentWeb();
                console.log(subWeb.get_title());
                console.log(subWeb.get_serverRelativeUrl());
                console.log(subWeb.get_url());
              }
        },
        function (sender, args) {
           console.log(args.get_message());
        }
       );   
    }
    
3
  • Tkx Youssef, but I followed all the steps but I have no result.
    – Raise
    Commented Sep 4, 2017 at 15:20
  • Ok Raise, i update it please try this one. Commented Sep 5, 2017 at 11:18
  • thank you very much for you time and help. I've found another solution too. using the content script editor. see the code link Below. enjoysharepoint.com/Articles/Details/…
    – Raise
    Commented Sep 7, 2017 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.