Skip to content

Instantly share code, notes, and snippets.

@klcodanr
Created July 16, 2019 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klcodanr/09498da6605597db08ef8a2b317a005c to your computer and use it in GitHub Desktop.
Save klcodanr/09498da6605597db08ef8a2b317a005c to your computer and use it in GitHub Desktop.
A simple script to dump out the renderings in a Sitecore 8 / 9 instance. To use, login to the instance, expand the nodes under renderings you want to log and then execute this script in the console.
var renderings = [];
var getName = function(el){
return el.querySelector('a span').innerText;
}
var isFolder = function(el){
return el.querySelector('a span img').src.indexOf('folder') !== -1;
}
var traverseTree = function(el, parentPath){
parentPath = parentPath+"/"+getName(el);
let children = el.children[3];
if(children){
children.childElements().forEach(function(child){
var rendering = parentPath+"/"+getName(child);
if(!isFolder(child)){
renderings.push(rendering);
console.log("Adding: "+rendering);
} else {
console.log("Skipping: "+rendering);
}
traverseTree(child, parentPath);
});
}
}
var root = null;
document.querySelectorAll('.scContentTreeNode').forEach(function(el){
if(getName(el) === 'Renderings'){
root = el;
}
});
traverseTree(root, "");
console.log(renderings.join("\n"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment