Home Forums General XMetaL Discussion XFTReplacement for first instance of element Reply To: XFTReplacement for first instance of element

Derek Read

Reply to: XFTReplacement for first instance of element

This will require some scripting to be added for the element you wish to display using XFT (which is configured in the CTM file). This is described in the XMetaL Developer help in the section that discusses CTM file settings…

[quote=Customization Guide “Display As” topic]If you select Dynamic Script, you must create a script for XMetaL to call before it displays the form. Use this script to create business rules that determine whether or not to display the form at run-time.

It goes on to provide an example, however, I think this is probably closer to what you are asking for:
[code]var aipc = Application.ActiveInPlaceControl;
if(aipc.node.previousSibling.nodeName == aipc.node.nodeName) {
aipc.ShouldCreate = false;
};
else {
aipc.ShouldCreate = true;
};[/code]

After you have built the project with XMetaL Developer (after hooking up your element using the XFT Form Wizard including setting up the “Dynamic Script” option) you will end up with something like the following in the CTM file.

[code]  
   
     myelement
           Embedded
     Replace
     ByScript
     JScript
      var aipc = Application.ActiveInPlaceControl;
if(aipc.node.previousSibling.nodeName == aipc.node.nodeName) {
aipc.ShouldCreate = false;
};
else {
aipc.ShouldCreate = true;
};
 ]]>

   

 
[/code]

Of course “myelement” would be the element you are displaying the XFT for (not sure in your case if that is “aa”, “bb” or “bbs”).

The logic here might not be exactly what you need. It checks to see if the element in question has a sibling element of the same name immediately preceding it. If it does then the form is not displayed. If it doesn't then the form is displayed.

So, it does what your post's title asks for. However, I'm not sure that's exactly what you need since your description throws me off a little bit. Hopefully you can work out your own logic based on this example.

Note that the ShouldCreate property is similar to that used when displaying ActiveX controls in place of elements.

Reply

Products
Downloads
Support