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

Atish Kumar Dipongkor
  • 13,371
  • 5
  • 32
  • 64
SandeshR
  • 1,992
  • 17
  • 67
  • 115
  • 1
    Can you try adapting an approach proposed in http://sharepoint.stackexchange.com/a/161900/50547 to query "__InheritsThemedCssFolderUrl" property of SPWeb? – Aziz Kabyshev Mar 18 '16 at 20:17

2 Answers2

6

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));
        }
    });
}
Atish Kumar Dipongkor
  • 13,371
  • 5
  • 32
  • 64
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

Colin
  • 4,665
  • 18
  • 26