Hooking Up An Essay To A Thdl Page

THL Toolbox > Developers' Zone > Web Development > THL Essays in Cocoon > Hooking up an Essay to a THL Page

Hooking up an Essay to a THL Page

Importing an Essay into an Existing THL Page Using the Hash

An essay can be included within any THL page by simply adding a hash beginning with “#essay=…” This will invoke the JavaScript that performs the AJAX call to Cocoon to render the XML into HTML and deliver that within the content section of the calling THL page. A standard example of this would be the Introduction to Sera essay by José Cabezón which has the URL:

external link: http://www.thlib.org/places/monasteries/sera/essays/#essay=/cabezon/sera/intro/

Note that the same essay can be shown anywhere on THL by simply changing the page URL before the hash (#) so that to display it on the THL homepage one would use:

external link: http://www.thlib.org/#essay=/cabezon/sera/intro/

Whenever an essay is imported into a page, its table of contents is inserted at the top of the side-column unless the <text> element of the essay’s XML has a rend attribute set to “no-toc”

Creating A PHP THL Page That Automatically Inserts Essay Content

The general format of a THL PHP page is to have a <div> whose id is "content" containing a <div> with a class of "shell-1". The main content of the page is generally within this "shell-1" class <div>. To get a page to automatically import the text of an essay, do the following:

  • Add a class "essaybody" to the <div class="shell-1">
  • Within that shell-1 <div> insert a single <a> element with:
    • its href attribute set to the cocoon path to the essay (that is, everything after the "#essay=" in the full URL)
    • a class attribute set to "essay"

An example of this is the external link: license page in THL Tools, which automatically includes the THL Text License when called. The code in this page looks as follows:

<!-- begin content -->
<div id="content">
  <div class="shell-1 essaybody">
    <a  href="/thl/text-license/"  class="essay" ></a>
  </div>
</div>
<!-- end content -->

Provided for unrestricted use by the external link: Tibetan and Himalayan Library