Is there any way we can check which on a site whether the theme is being inherited from the parent site using jQuery/JavaScript
2 Answers
I hope OP meant following thing from site settings.
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));
}
});
}
-
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?– SandeshRCommented Mar 21, 2016 at 17:44
-
1Under 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
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
__InheritsThemedCssFolderUrl
" property of SPWeb?