如何在Tridion中获取当前字段名称?(How to get the current field name in Tridion?)

编程入门 行业动态 更新时间:2024-10-11 17:24:38
如何在Tridion中获取当前字段名称?(How to get the current field name in Tridion?)

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

I adding a button to the ribbon tool bar in Tridion 2011 SP1. When I click on the button it will open an aspx page.Inside that aspx page I need to access the current field name where the cursor is presently. Please provide me which object to be used? For schema name I used $display.getView().getItem().getSchemaId(). Similarly is there any way to get the current field name?

最满意答案

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

$display.getView().getSourceEditorName()

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

如果你想从弹出窗口获得相同的值,请在opener上调用它,如下所示:

opener.$display.getView().getSourceEditorName()

更好的方案

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

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 }); }

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

var fieldName = window.dialogArguments.fieldName;

The closest I got is using this code (in the Component edit window):

$display.getView().getSourceEditorName()

This will return the name of the current field, even though the method name suggests it does something else.

If you want to get the same value from your popup, call it on the opener like this:

opener.$display.getView().getSourceEditorName()

Better solution

Instead of looking up the field name from within the popup, you should really pass it into your popup as a argument when your command is invoked. You can get it from the target parameter that is passed to the _execute method of your Command.

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 }); }

And then read it in your popup's JavaScript using:

var fieldName = window.dialogArguments.fieldName;

更多推荐

本文发布于:2023-07-29 05:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1313041.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   名称   如何在   field   Tridion

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!