Skip to content

Instantly share code, notes, and snippets.

@chrismrgn
Last active August 29, 2015 14:12
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 chrismrgn/c34c5f449786cafda7bf to your computer and use it in GitHub Desktop.
Save chrismrgn/c34c5f449786cafda7bf to your computer and use it in GitHub Desktop.
OpenSchema.js
javascript: (function (UI, B, e, a, r, d)
{
if ( typeof String.prototype.endsWith != 'function' ) {
String.prototype.endsWith = function( str ) {
return this.substring( this.length - str.length, this.length ) === str;
}
};
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.getTypeName().endsWith('Component'))
{
console.log('Got a Component');
var schema = item.getSchema();
schema.load();
setTimeout(function(){
var schemaTCM = item.getSchemaId();
var schemaTCMArray = schemaTCM.split('-');
var parentPublicationTCM = schema.getOwningPublicationId();
var parentPublicationTCMArray = parentPublicationTCM.split('-');
var parentPublicationId = parentPublicationTCMArray[1];
schemaTCMArray[0] = 'tcm:'+parentPublicationId;
var parentSchemaId = schemaTCMArray.join('-');
var win = window.open('/WebUI/item.aspx?tcm=8#id='+parentSchemaId, '_blank');
win.focus();
}, 500);
}
else
{
alert('Only works on Components');
}
}
catch (x) {alert(x);};
})(window.top, 'DashboardView', 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment