npsEdit

Using the npsStream and npsEdit elements, content such as the main content or the value of an HTML field of a file version can be passed from within a wizard to an editor such as the HTML editor. Please proceed as follows to achieve this:

First, read the data to be edited as a stream and store the ticket ID that is returned in a variable. For the main content, you can use the following command for this:

set ticketId [obj withId objectID editedContent get blob.stream]

As the objectID you can use, for example, the ID you received via the name parameter of the npsSelectObject element. For version fields the field value needs to be queried first and then stored as a stream:

set value [content withId contentID get fieldName ]
set ticketId [stream uploadBase64 [base64:encode $value]]

In both cases the ticket ID is stored in a variable. The ID is required for passing the data to be edited to the Content Management Server by means of the npsStream instruction. Additionally, the npsStream instruction is given the MIME type of the data and the path of the CMS file concerned plus an ID, which can be chosen freely, for referring to the data later on in the npsEdit instruction:

set path [obj withId objectID get visiblePath]
npsStream ticket="$ticketId" mimeType="text/html" path="$path" id="htmlData"

Then the npsEdit instruction can be used, specifying the reference ID determined above (htmlData), to include an editor in the wizard page:

<npsEdit editor="html" stream="htmlData"/>

By means of the editor specification, all editors available in the CMS can be included: html: HTML editor, external: local application, tinymce: TinyMCE, internal: internal editor (text input area).

Please note that the text modified by means of the editor is only saved in a stream if one of the wizard buttons ok or next (observe case) is used to leave the wizard page from which the editor was opened.

Since selecting a file by means of a wizard, editing it, and storing it again can be done on different pages (meaning that the ticket ID may change in the course of editing), the GUI passes in the wizard.tickets variable a list of stream IDs and the ticket IDs associated with them to the wizard. This makes it possible to determine the ticket ID by means of the chosen stream ID (here htmlData):

proc wizardEditor {params args} {
  array set tickets [getParam wizard.tickets]
  set ticketId [getKey tickets htmlData]
...

Finally, the edited data can be written back to the file version. For a main content, use:

obj withId objectId editedContent set blob.stream $ticketId

For other fields, the content needs to be read first and then stored as a field value:

set value [base64:decode -asString [stream downloadBase64 $ticketId]]
obj withId objectId editedContent set fieldName $value