Embed Live Content in HTML Pages or Messages

You can embed live content in wiki pages or messages by inserting web parts or dependencies using substitution syntax. For example, you might embed a live table of currently open issues on a status page, or include a key visualization to illustrate a point in the description of your research protocol.

This feature lets you:

  • Embed a web part or visualization in an HTML wiki page or message.
  • Combine static and dynamic content in a single page. This eliminates the need to write custom modules even when complex layout is required.
  • Embed wiki page content in other wiki pages to avoid duplication of content (and thus maintenance of duplicate content). For example, if a table needs to appear in several wiki pages, you can create the table on a separate page, then embed it in multiple wiki pages.
  • Indicate JavaScript or CSS files that are required for code or styles on the page; LabKey will ensure that these dependencies are loaded before your code references them.
Embedding web parts and dependencies is available only on pages and messages that use HTML format.

Security rules are respected for inserted web parts. To see inserted content, a reader must have viewing permissions for both:

  • The displaying page.
  • The source container for the content inserted in the page.

Only administrators and members of the Developers group can create or edit HTML pages that include <script> tags.

Embed Web Parts

To embed a web part in an HTML wiki page, open the page for editing and go to the HTML Source tab. (Do not try to preview using the Visual tab, because this will cause <p> tags to be placed around your script, breaking it.) Use the following syntax, substituting appropriate values for the substitution parameters in single quotes:

${labkey.webPart(partName='PartName', showFrame='true|false', namedParameters…)}

Web Parts

You can find the web part names to use as the 'partName' argument in the Web Part Inventory. These names also appear in the UI in the Select Web Part drop-down menu.

Configuration Properties for Web Parts

The Web Part Configuration Properties page covers the configuration properties that can be set for various types of web parts inserted into a web page using the syntax described above

Examples and Demos

See Examples: Embedded Web Parts. That page includes a link to the HTML source for its samples.

Wiki Example. To include a wiki page in another wiki page, use:

${labkey.webPart(partName='Wiki', showFrame='false', name='includeMe')}

where includeMe is the name of another wiki page in the same folder.

For a wiki page in a different container, use the webPartContainer property. To get the webPartContainer for the source container, see Web Part Configuration Properties.

${labkey.webPart(partName='Wiki', showFrame='false', webPartContainer='e7a158ef-ed4e-1034-b734-fe851e088836' name='includeMe')}

Search Example. The following snippet embeds a Search web part in a wiki page. Setting location='right' means that the narrow wiki part is used, so the web part will display in the right column of a page.

${labkey.webPart(partName='Search', showFrame='false', location='right', 

Files Example. The following snippet embeds a Files web part in a wiki page.

<div id='fileDiv'/>
<script type="text/javascript">

var wikiWebPartRenderer = new LABKEY.WebPart({
partName: 'Files',
renderTo: 'fileDiv'

Table of Contents Example.

${labkey.webPart(partName='Wiki Table of Contents', showFrame='false')}

Embed Client Dependencies

You can also embed dependencies on other JavaScript or CSS files into your wiki using similar syntax.

${labkey.dependency(path='path here')}

For example, your wiki could include a line like the following:


See also Declare Dependencies.

AJAX Example. Use the client API to dynamically AJAX webparts into an HTML page:

<div id='tocDiv'/><br/> 
<div id='searchDiv'/>
<script type="text/javascript">
var tocRenderer = new LABKEY.WebPart({
partName: 'Wiki TOC',
renderTo: 'tocDiv'
tocRenderer .render();

var tocRenderer = new LABKEY.WebPart({
partName: 'Search',
renderTo: 'searchDiv'
tocRenderer .render();

Related Topics


expand all collapse all