| How to dynamically modify the Table of Contents? |
The Table of Contents (TOC) in your ebook or publication can be modified at runtime thanks to HEScript. This topic explains you how you can show and hide TOC items at runtime. For instance, you want to display some TOC items only if the publication works in Registered mode. Associating HEScript functions to TOC items
This property can point to a Boolean HEScript function that defines whether the TOC entry is visible or not. The syntax should be: [scriptname].[booleanfunctionname] When the publication loads the TOC, if a TOC item is associated to a Boolean function, the latter is executed. If its result is True, the TOC item is displayed; otherwise, if the result is False, the TOC item is hidden.
ExampleThis sample hides TOC items if the publication works in Trial mode, and shows them if it is in Registered mode. 1. Go to the Script Manager, edit the "UserMain" script and copy/paste the following code: function HideItIfTrial: Boolean;
begin
// Returns False to hide the TOC item if HEPubRegistered is set to 1 (Registered)
Result := GetGlobalVar("HEPubRegistered", "0") = "1";
end; 2. Close the script editor, go to the Table of Contents page and choose the TOC item you want:
Enter the reference to the script function: UserMain.HideItIfTrial or select it with the "..." button. Press Enter to save changes. 3. Make sure you have enabled the option to make a Trial publication and compile it. |
This is the online documentation of HTML Executable.
About HTML Executable
HTML Executable is a versatile HTML compiler and ebook compiler: it lets you create secure ebooks and desktop applications with your websites, HTML or PDF documents.
You can easily create attractive ebooks, full-featured HTML applications (RIA) and software, digital publications from your websites, PDF files and HTML documents for online or offline distribution.