Created
July 16, 2019 03:34
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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