How to get the name of the current field in Tridion?

I add a button to the ribbon toolbar in Tridion 2011 SP1. When I click on the button, it will open an aspx page. Inside this aspx page, I need to access the current name of the field where the cursor is located. Please provide me which object to use? For the schema name, I used $display.getView().getItem().getSchemaId() . Similarly, is there a way to get the name of the current field?

+4
source share
1 answer

The closest I got using this code (in the component editing window):

 $display.getView().getSourceEditorName() 

This will return the name of the current field , although the method name assumes that it is doing something else.

If you want to get the same value from your popup, name it opener as follows:

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

The best decision

Instead of looking for the field name from the popup, you should pass it to your popup as an argument when invoking your command. You can get it from the target parameter, which 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 a popup javascript using:

 var fieldName = window.dialogArguments.fieldName; 
+6
source

Source: https://habr.com/ru/post/916235/


All Articles