问题
I implemented a ribbon tool bar button for Tridion 2011 SP1, which opens an aspx page and populates a drop down list based on a look-up component. The look-up component comprises of different embedded schemas. To filter out the values based on embedded schema name I need to get the Embedded schema field values of component creation page on button click in button JavaScript.
Because in my component creation page consists of multivalued Embedded schema field has the info, which helps look up value filtering process. I am unaware of the command need to be used for the requirement. I know about a command to get the complete component XML, that is: $display.getView().getItemFields()
.
To get the present RTF field content I am going for the command: target.editor.getHTML()
. To get the complete set of Embedded schema field values only,
which command I need to use?
My sample component source:
<root>
<a>sample a</a>
<b>sample b</b>
<c>
<ca>ca 1</ca>
<cb>cb 1</cb>
<cc>cc 1</cc>
</c>
<c>
<ca>ca 2</ca>
<cb>cb 2</cb>
<cc>cc 2</cc>
</c>
<c>
<ca>ca 1</ca>
<cb>cb 1</cb>
<cc>cc 1</cc>
</c>
</root>
回答1:
I don't think there are public API for that. But you could use component data xml and then parse it by yourself:
var item = $display.getItem();
var xml = item.getContent(); // OR $display.getView().getItemFields();
var xmlDoc = $xml.getNewXmlDocument(xml);
var schema = item.getSchema();
if(schema.isLoaded())
{
var xpath = "/custom:{0}/custom:embeddedFieldName".format(schema.getRootElementName());
var fields = $xml.selectNodes(xmlDoc, xpath, { custom: schema.getNamespaceUri() });
// loop fields and get values ...
}
来源:https://stackoverflow.com/questions/10715078/how-to-get-the-complete-set-of-embedded-field-values-in-a-popup-window-in-the-tr