如何在Tridion中获取当前字段名称?

P.M*_*hna 4 tridion

我在Tridion 2011 SP1的功能区工具栏中添加了一个按钮.当我点击按钮时,它将打开一个aspx页面.在aspx页面旁边,我需要访问当前光标所在的当前字段名称.请告诉我使用哪个对象?对于我使用的模式名称$display.getView().getItem().getSchemaId().同样有没有办法得到当前的字段名称?

Fra*_*len 6

我得到的最接近的是使用此代码(在组件编辑窗口中):

$display.getView().getSourceEditorName()
Run Code Online (Sandbox Code Playgroud)

这将返回当前字段名称,即使方法名称表明它执行其他操作.

如果您想从弹出窗口中获取相同的值,请按以下方式调用它opener:

opener.$display.getView().getSourceEditorName()
Run Code Online (Sandbox Code Playgroud)

好的解决方案

不要在弹出窗口中查找字段名称,而应该在调用命令时将其作为参数传递给弹出窗口.您可以从target传递给_executeCommand方法的参数中获取它.

GUI.Extension.prototype._execute = function GUI$Extension$_execute(target) {
    target.editor.setFocus();
    var fieldName = target.item.getSourceEditorName();
    var popup = $popup.create("/WebUI/Editors/GUI.Extensions/Extension.aspx",
                "width=400px,height=150px,resizable=0",
                { fieldName: fieldName });
}
Run Code Online (Sandbox Code Playgroud)

然后使用以下命令在弹出窗口的JavaScript中读取它:

var fieldName = window.dialogArguments.fieldName;
Run Code Online (Sandbox Code Playgroud)

  • 你做了什么?我已经为你做了很多基础工作来得到上面的答案.你不能依赖别人来深入研究Tridion的GUI代码.搜索字段的相关性,记录您的发现,然后询问后续问题. (4认同)