Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the schema name from the schema object in Tridion?

As part of implementing the Button to the ribbon tool bar. I require the schema name in the Button java script file. So I am trying to use the following command to get the schema object.

$display.getView().getItem().getSchema();

The above command will return the schema object. But how to get the schema Title from the schema object. Please help me out in this. Thanks in advance. Early response is appreciated.

like image 465
P.Muralikrishna Avatar asked Jun 29 '12 07:06

P.Muralikrishna


1 Answers

You need to load the item info by calling .load(true) on the schema object. Because (obvious) not all info is loaded because of performance reasons.

Since the .load() call is asynchronous, you have to use a callback function to 'know' when the loading is done.

You can use the following code to load the item and to read it's properties (code simplified):

var schemaObject = $display.getView().getItem().getSchema();
function loaded()
{
    alert(schemaObject.getTitle());
}
$evt.addEventHandler(schemaObject, "load", loaded);
schemaObject.load(true);
like image 136
Albert Romkes Avatar answered Oct 24 '22 22:10

Albert Romkes