Leaning rather heavily on Chris Morgan's WebdavURL bookmarklet, I set out to make one which would copy the human-readable path to an item (which might be preferred by non-techies in documentation)
A quick detour to the anguilla documentation found me the methods .calculatePath() and .getTitle() - a quick regex-strip and all would be good.... here's the code (with some added whitespace goodness)
javascript: (function (UI, B, e, a, r, d) {
try {
while (r = UI.frames[e++]) {
if ((a = r.$display && r.$display.getView()) && a.getId() == B) {
d = a; break;
}
}
var m1 = window.top.frames[1];
var itemId = d.getMainInterface().getListSelection().getVersionlessIds()[0];
var item = m1.$models.getItem(itemId);
if(item != undefined) {
item.loadWebDavUrl(); setTimeout(function() {
var itemPath = item.calculatePath()
.replace(/^\\Content Management/, "")+"\\"+item.getTitle();
alert(itemPath);
}, 400);
} else {
alert('Please select an item...');
}
} catch (x) {
alert('Please select an item...');
};
})(window.top, 'DashboardView', 0)
Unfortunately, while .calculatePath() works like a dream, .getTitle() seems only to work some of the time, so on other occasions I just get 'undefined' for the title. So far, I have not been able to identify, say, a particular item type that is doomed to failure. It appears to be random, no matter how alien a world-view this may be for me.
I would love to blame Tridion (maybe select is broken), but I fear it is my own interpretation of scripture that is at fault. Can anyone steer me from the rocky path of waywardness?
.getTitle()
needs a loaded item or should always have a result. See tridion.stackexchange.com/questions/2695/… for an example of how to load an item.