AnsweredAssumed Answered

Sites root-scoped javascript variable not defined.

Question asked by vamirr on Aug 24, 2011
Latest reply on Nov 2, 2012 by mikeh
Greetings,

I'm attempting to modify the Share footer webscript to include some information found in an aspect applied to each site.


The javascript API docs show that there is a root scoped variable 'sites' that gives access to the sites service.   My code below fails on the use of that root scoped variable with the error that it is not defined.

Any thoughts on what I'm missing?    Why is sites undefined when it's supposed to be a root scoped variable? How else should I be getting the site's scriptNode from its shortName?

function main(){
        profile = context.properties["site-profile"]

        if(profile){
                mySite = sites.getSite(profile.shortName);    //fails here…
                mySiteNode = mySite.node;

                if(mySiteNode){
                        if(mySiteNode.hasAspect("ac:siteProps")){
                                model.siteSponsor = mySiteNode.properties["ac:sponsor"];
                        }
                        else{
                                //aspect not applied.
                        }
                }
        }
}
main();

Outcomes