onPageModify - event of object PmWebDir

The event fires for the possibility to change the sent HTML/XML document. It fires after all changes of the document has been finish (including automatic replacing of keywords) and before sending the document into the Web browser.
pMe(Object) Reference to the PROMOTIC object where the event rises.
pEvent(Object) A referrence to object describing detailed information about the specific event.
pEvent.User - (Object) The User object that represents authorized user, who called the request for this page.
pEvent.FilePath - (String) Relative path to the file that is requested from the Web browser.
pEvent.PageString - (String) Text string that contains the whole required HTML/XML document in the text form after the automatic replacing of keywords has been made. If the required file isn't a HTML/XML document, then this string is empty. The algorithm can change the content of the document by writing into this property.
pEvent.Modify - (Boolean) If the pEvent.PageString property has been changed, then the value of the property has to be set to true. Otherwise changes won't be accepted.

If Data source = Text set to pEvent.PageString property in onPageModify event, then the pEvent.Modify property is preset to true.

- If Data source = Text set to pEvent.PageString property in onPageModify event, then using this event is recommended only for special cases. Because this event is fired after replacing the keywords in the document, it is needless to change the keywords here. More simple way to change the sent document is by the onPageLoad event, which is fired just before keywords replacing. See also Example1.
- If Data source = Text set to pEvent.PageString property in onPageModify event, then this event is the only option to fill in the sent data.
Suppose we have a user html page on the disc (Page.html) where we require the _(XXXXX)_ keyword to be replaced in the text, for example by the user name. The replacement is performed by the StringReplace method.
Text in HTML page:
Script in onPageModify event:
VBScriptSelect and copy to clipboard

If pEvent.FilePath = "Page.htm" Then
  Dim sReplaced
  sReplaced = Pm.StringReplace(pEvent.PageString, "xxxxx", pEvent.User.Name)
  pEvent.Modify = true
  pEvent.PageString = sReplaced
End If
Example of sending very simple HTML pages dynamicaly created directly in this event's script. The Data source configurator must be set to "Text set to pEvent.PageString property in onPageModify event".
VBScriptSelect and copy to clipboard

Dim s
Select Case pEvent.FilePath
Case "abc.htm"
  s = "<html><head><title>abc</title></head>"
  s = s & "<body><p>Temperature = "
  s = s & pMe.Pm("/Data/#vars/temperature").Value
  s = s & "</p></body></html>"
Case "fff.htm"
Case Else
End Select
pEvent.PageString = s
PROMOTIC 8.3.30 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice