1.4
Table Of Contents
- Table of Contents
- Welcome to PlanetPress Connect 1.4.2
- Setup And Configuration
- DataMapper Module
- The Designer
- Mark Position Options
- Additional Text Settings
- Additional Image Settings
- Barcode Options
- Codabar Settings
- Code 128 Settings
- Code 39 Settings
- Additional Datamatrix Settings
- Additional EAN 128 Settings
- Additional EAN 13 Settings
- Additional EAN 8 Settings
- Additional Interleave 2 of 5 Settings
- Additional PDF417 Settings
- Additional QR Code Settings
- Additional UPC A Settings
- Additional UPC E Settings
- Additional OMR Mark Settings
- Keystore
- PDF Signature
- Copyright Information
- Legal Notices and Acknowledgements
Loading a snippet via a script
Instead of dragging it into the content directly, it is possible, and often very useful, to load a
snippet dynamically. Create a script (see "Write your own scripts" on page 376) and in the
code, use the following function:
results.loadhtml(‘snippets/nameofthesnippet.html’)
This function will insert the snippet in the content at any position where the script's selector is
encountered.
For more examples, see Skin/Formats/CrossReferencePrintFormat("loadhtml() Global function
thatreplaces the content (inner html) of each matched element in the result set, alternatively
load the data into a variable.The location should be an URL or a relative file path. loadhtml
(location)loadhtml(location, selector) Loadhtml() iscached per batch run (based on the URL) in
print/email. loadhtml(location) Loads allHTML from the HTML file. locationString containing a
path that can be absolute or relative to the section/context. Use: snippets/<snippet-name> to
retrieve the content from a HTML fileresiding in the Snippets folder on the Resources
panel.ExamplesThis script loads a local HTML snippet (from the Resources panel) directly into
the matched elementsresults.loadhtml("snippets/snippet.html");The following script loads a
local HTML snippet (Resources panel) into a variableThe replaceWith()command is used to
replace the element(s) matched by the script's selector with the contents of the snippet.var
mysnippet = loadhtml('snippets/snippet.html'); results.replaceWith(mysnippet);Same result as
the previous script, but a different notation:results.replaceWith(loadhtml
('snippets/snippet.html'));The following script loads a snippet into a variable and finds/replaces
text in the variable before inserting the content into the page. The second find command also
adds formatting to the replacing text.var mysnippet = loadhtml('snippets/snippet.html');
mysnippet.find('@var1@').text('OL Connect 1'); mysnippet.find('@var2@').html('<i>OL Connect
2</i>').css('text-decoration','underline'); results.replaceWith(mysnippet); This last script loads a
snippet into a variable and retrieves an element from the snippet using query().var mysnippet =
loadhtml('snippets/text-root-wrapped.html'); var subject = query("#subject", mysnippet).text();
results.append("<p style='font-weight: bold;'>" + subject + "</p>");loadhtml(location, selector)
Retrieve specific content from the filename. locationString; the location can be absolute or
relative to the section/context. Use: snippets/<snippet-name> to retrievethe contentfrom a
HTML fileresiding in snippets folder of the Resources panel.selectorString. The supplied
selector should conform to CSS selector syntaxand allows you to retrieve only the content of
matching elements.ExamplesThis script loads a specific element from the snippet.var
mysnippet = loadhtml('snippets/snippet-selectors.html','#item3'); results.replaceWith
(mysnippet);This script loads the children of the selected element.var snippet = loadhtml
('snippets/snippet.html','foobar').children(); results.replaceWith(snippet);Another example is
given in the following how-to: Using a selector to load part of a snippet." on page 1).
Page 386