Configuration
To use the HTML post-processing service, it is necessary to instantiate it and configure its Property Bag
properly. For more information see: Adding Service Instances and Property Bag.
When configuring the value of the Property Bag
, the file path will be relative to the application's classpath and should not start with /
. It can be the path of the file within a module
installed in LumisXP.
The Service has the object lum_processor
which in turn has the following attributes:
- Attribute
html
. By usinglum_processor.html
in the script file, we will have the HTML of the page returned as aString
. - Attribute
request
. By usinglum_processor.request
in the script file, an object of type IPageWebResourceRenderRequest will be returned.
Implementation Example
Imagine that we have a situation where an interface of a news service instantiated in a channel with friendly URLs enabled needs to change a portion of the generated HTML by injecting, for example, an image to accompany the title (represented by the image lumis/portal/client/images/Edit.gif). Additionally, let's say this service has local groups for different locations. We want to add this image only for the channel related to RJ. To do this, we will use both attributes html
and request
. Initially, we have the list of news as shown in the figure below:
To achieve the goal, the following js code will be used which utilizes Jsoup
to add the image in the HTML attribute corresponding to the title (News1). Thus, the image will be added to all HTML pages where the title appears and belongs to RJ, if it exists:
The value returned by the last command in the script file will be the value used as the HTML of the page. Thus, the title in the news list will start to show the image, since the path of its WebResource
contains "rj":
Note that all HTML child pages of the parent channel where the service was instantiated and that have "rj" in the path of their WebResource
will be affected. Therefore, the details page will also display the image as shown in the figure below: