Page 1 of 1

Web Graphic Placeholder Replacement

PostPosted: Fri Oct 06, 2017 8:28 pm
by Clifton
The page below is using a web graphic placeholder created by using setHTMLContent():

The PowerPac provides several methods for dynamic web graphic placement.
  1. setHTMLContent()
  2. pgStyleObject()
    set the background style to a url like this: url(../media/myGraphic.png)
  3. Style sheets loaded with pgExtFiles()
    Create a style class in the stylesheet that sets the background to a url and load the stylesheet with pgExtFiles(). Then, assign the class to an object on your page by using the PowerPac function userProperty().
  4. XML configuration files that set the html content of the object in question.
    Please visit the XML Configurations section of this forum.
All of the above methods allow for dynamic replacement at any time based on user interaction, etc. A major advantage of using the PowerPac this way is that it can provide png file support to ToolBook versions which lack such support (e.g.: ToolBook v9). PNG files allow for alpha transparency which allow for much better graphics in your applications.

EXAMPLE:
Here is a typical way this could be accomplished using the Actions Editor using setHTMLContent().

Create a ToolBook page with a field into which you want to load your web graphic. In the example below I named the field "myGraphic" for the sake of this example.
Image 1.png
ToolBook page with field "myGraphic"
Image 1.png (29.06 KiB) Viewed 6568 times

Add an action to the field for the on load page that executes setHTMLContent() with the content set to your graphic.
Image 2.png
On load page action using setHTMLContent()
Image 2.png (30.3 KiB) Viewed 6568 times

Include your graphic as an external resource to be included when the book is exported by using the PowerPac menu item Add folders to export tree . . .
Image 3.png
Add graphic to the export tree for the book
Image 3.png (85.14 KiB) Viewed 6568 times

Export your book to see the results. ENJOY!