3

Is there any way we can check which on a site whether the theme is being inherited from the parent site using jQuery/JavaScript

1

2 Answers 2

6
+100

I hope OP meant following thing from site settings.

enter image description here

To check whether this option is checked or not, we need to make a REST call to the following end-point

/_api/Web/AllProperties

It will return all properties under the web. Now find the property named OData__x005f__x005f_InheritsThemedCssFolderUrl. If it's value is "True", then the theme is being inherited from the parent.

Sample Code

function isThemeBeingInheritedFromParent() {
    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/AllProperties",
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
        },
        success: function(data) {
            if (data.d.OData__x005f__x005f_InheritsThemedCssFolderUrl == "True") {
                console.log("Theme is inherited");
            } else {
                console.log("Theme is not inherited");
            }
        },
        error: function(error) {
            alert(JSON.stringify(error));
        }
    });
}
3
  • Hi Atish, Thanks for the answer.. just want to know is there a property which contains the url of the parent site from where the theme is inheriting?
    – SandeshR
    Commented Mar 21, 2016 at 17:44
  • 1
    Under this end-point, there is no such property. You can try /_api/Web/ParentWeb Commented Mar 22, 2016 at 9:19
  • Knives in donkeys hand My words for those who down votes without comment!!! Commented Mar 24, 2016 at 16:12
1

You might be able to get the theme info of the current and the parent web and compare them. if they are the same, you could say the theme was inherited (what's the point of applying a theme to a site specifically and have it be the exact same as it's parent, right?)

So here is the setting of a theme part (with JSOM) Apply theme to subsite from SharePoint hosted app + javascript

More info on inheriting How do I Inherit the CSS Theme Color in my Sharepoint 2013 App?

And getting themeinfo for a site (CSOM, but should work in JSOM too) https://msdn.microsoft.com/en-us/library/office/dn985872.aspx

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.