Information Classification: External Restricted.
See https://www.chili-publish.com/security

Manipulating Snippet Frames

You can find more information on the properties available for snippet frames on Document Object Model - SnippetFrame

Clearing content

You can call:

function ClearFrame()
{
   var f = editor.GetObject("document.selectedFrame");
   if (f != null)
   {
      if (f.type == "snippet")
      {
         editor.ExecuteFunction("document.selectedFrame","ClearContent");
      }
   }
}

Assigning a new snippet doc.

Using the ID of the new snippet document (which you can retrieve from the server using various webservice calls), you can assign a new snippet to a frame with:

function SetSnippetContent(snippetID)
{
   var f = editor.GetObject("document.selectedFrame");
   if (f != null)
   {
      if (f.type == "snippet")
      {
         editor.SetProperty("document.selectedFrame","snippetDocID",snippetID)
      }
   }
}

NOTE: if you are assigning the same snippet document ID to a frame (which already contained said document), this will not be applied (as the Editor will assume this to be a redundant call). To force the update, you will either need to call the ClearContent function (see higher), or first set the snippetDocID property to an empty string.

Adding a new snippet directly as frames

You can add a snippet frame to the editor directly as frames:

function insertSnippet(snippetID){
     editor.ExecuteFunction('document.pages[1].frames', 'Add', 'snippet', '1in', '1in', '1in', '1in');
     editor.SetProperty("document.selectedFrame","placeAsFrames",true);
     editor.SetProperty("document.selectedFrame", 'snippetDocID', snippetID);
}

 

Reloading a placed snippet

To reload the placed snippet document (for example after editing it in a separate Editor popup window), you can call (starting version 3.0.4.1):

function ClearFrame()
{
   var f = editor.GetObject("document.selectedFrame");
   if (f != null)
   {
      if (f.type == "snippet")
      {
         editor.ExecuteFunction("document.selectedFrame","ReloadSnippetDoc");
      }
   }
}

 

Accessing the snippet document

Once the snippet has been placed and its document has been loaded, you can access the document itself using "snippetDoc" als part of the descriptor (eg, when starting with the selected frame: "document.selectedFrame.snippetDoc").

NOTE: this is ONLY used inside the normal Editor functionalities to update variable or color values. While other uses are imaginable, please be aware that they have never been executed, and are not part of the normal testing procedures.

function AccessDocument()
{
   var f = editor.GetObject("document.selectedFrame");
   if (f != null)
   {
      if (f.type == "snippet")
      {

         var snippetFrame = editor.GetObject("document.selectedFrame");
         if (snippetFrame.docLoading == false)
         {
           var numVariables = editor.GetObject("document.selectedFrame.snippetDoc.variables").length;
           alert(numVariables);
         }
       }
   }
}

 

Accessing Variables inside snippets

To access variables in a placed snippet document, which is used from inside the normal editor features as well, you can use a descriptor which starts from the placed document:

 

editor.SetProperty("document.selectedFrame.snippetDoc.variables[MY_VAR_NAME]","value", "NEW VALUE");

Converting to Frames

You can use:

function Convert()
{
   var f = editor.GetObject("document.selectedFrame");
   if (f != null)
   {
      if (f.type == "snippet")
      {
           editor.ExecuteFunction("document.selectedFrame","ConvertToFrames");

       }
   }
}

All information on this page must be treated as External Restricted, or more strict. https://www.chili-publish.com/security