Changeset 8936


Ignore:
Timestamp:
2005-02-01T14:26:20+13:00 (19 years ago)
Author:
kjdon
Message:

first draft of hyperlinking metadata elements faq entry. Michael has promised to tidy this up.

Location:
trunk/greenorg/macros
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/greenorg/macros/english.dm

    r8880 r8936  
    10431043
    10441044_tfaqcustomizeformattitle_ {What are the formatting options available for my collection?}
     1045
     1046_tfaqcustomizemetadatalinkingtitle_ {How can I hyperlink individual metadata elements?}
     1047
    10451048_t207_ {FAQ Main Page}
    10461049
     
    18611864<p>
    18621865<i><u>Extended metadata names</u></i><br>
    1863 There are a few options for displaying metadata. The basic way is to specify e.g. [Title] or [dc.Title]: this displays the value of that particular metadata element for the current document/section. Metadata names can be prefixed by parent: or sibling. The following examples all use Title or Subject metadata, but any metadata could be used, including ones with namespaces (e.g. dc.Title).
     1866There are a few options for displaying metadata. The basic way is to specify e.g. [Title] or [dc.Title]: this displays the value of that particular metadata element for the current document/section. Metadata names can be prefixed by parent: or sibling. The following examples all use Title or Subject metadata, but any metadata could be used, including ones with namespaces (e.g. dc.Title). Any metadata name can also be prefixed by "cgisafe:". This results in the value being formatted so that it is safe to put in a URL.
    18641867<p>
    18651868<table class="faq-table">
     
    18701873<tr><td>[sibling:Subject]</td><td>All Subjects of the current section, separated by ", ". This is used for displaying metadata where there is more than one value. [Subject] will just display the first value.</td></tr>
    18711874<tr><td>[sibling(All:'&lt;br&gt;'):Subject]</td><td>All Subjects of the current section, separated by &lt;br&gt;. </td></tr>
     1875<tr><td>[cgisafe:parent(Top):Title]</td><td>The Title of the topmost parent section, made safe for URLs.</td></tr>
     1876<tr><td>[cgisafe:sibling(All:'&lt;br&gt;'):Subject]</td><td>All Subjects of the current section, separated by &lt;br&gt;, made safe for URLs.</td></tr>
    18721877</table>
    18731878
     
    18951900}
    18961901
     1902_tfaqcustomizemetadatalinking_ {
     1903<i>[contributed by Axel Schild]</i><br/>
     1904When a metadata element has only one value, it is easy to make a hyperlink out of the value. In the format statement, you just put an &lt;a&gt; tag around the metadata item, for example:
     1905<br><small><tt>&lt;a href="url to link to"&gt;[dc.Subject]&lt;/a&gt;</tt></small><br>
     1906When the metadata item has multiple values, and you want to link each one separately, it is a bit more difficult. The following is Axel's solution to his particular problem: display all the Creator elements, each one hyperlinked to a search of that Creator, in the Creators index. 
     1907<p>
     1908Use the format string below in the collect.cfg file (for my collection I put this string in "format DocumentText" statement)
     1909<br><small><tt><pre>
     1910\{If\}\{[dc.Creator],
     1911&lt;tr&gt;
     1912&lt;td align=right valign=top&gt;&lt;b&gt;Authors:&lt;/b&gt;&lt;/td&gt;
     1913&lt;td align=left valign=bottom&gt;&lt;label name=AuthorField id=AuthorField&gt;
     1914\_httpquery\_;[cgisafe:sibling(All:\\' ; \\'):dc.Creator];[sibling(All:\\'\_\\'):dc.Creator]
     1915&lt;/label&gt;&lt;/td&gt;
     1916&lt;/tr&gt;\}
     1917</pre></tt></small>
     1918This statement includes a label definition with the name "AuthorField". "\_httpquery\_" is a macro which resolves into the http-address of query page of the collection. "[cgisafe:sibling(All:\\' ; \\'):dc.Creator]" displays all Creators, separated by ; with all special characters replaced with UTF-8 encoding, so that it can be used  within a web address. [sibling(All:\\'\_\\'):dc.Creator] produces a similar string without replaced special characters. Notice the different separation symbols, these are needed later on.
     1919<p>
     1920Additional changes have to be made in order to make this whole thing work. You further need to change the \_header\_ or \_textheader\_ macro in the package of the page the format string will be displayed in (in my case the document package). The change is that \_htmlhead has to be parametrized with
     1921
     1922<small><tt>\_htmlhead\_(onload="ExtractAuthors();")</tt></small>, where ExtractAuthors(); is a Javascipt function, which is called on loading the corresponding page (the document display page). Since you do not want to mess in the standard macro files, create an extra.dm file (should be placed in gsdl/collect/&lt;collnanme&gt;/macros) and override the chosen macro with a collection specific macro. In my example this is done by the code sequence
     1923
     1924<br><small><tt><pre>
     1925package document
     1926
     1927###document display
     1928
     1929###HTML-Page Header
     1930\_textheader\_ [c=exacol] \{\_cgihead\_
     1931\_htmlhead\_(onload="ExtractSubjects();ExtractAuthors();")
     1932&lt;center&gt;
     1933&lt;table width=_pagewidth_&gt;&lt;tr&gt;&lt;td align=right&gt;
     1934\_icontab\_\_javalinks\_&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
     1935&lt;/center&gt;
     1936\}
     1937</pre></tt></small>
     1938Now all that is missing is the Javascript function which has to be included into the \_pagescriptextra\_ macro of the same package. Copy this macro out of the corresponding standard macro file and paste it into your extra.dm file. Make the neccessary modification which is in my case
     1939<br><small><tt><pre>
     1940### Self-made Javascript functions
     1941\_pagescriptextra\_\{
     1942function ExtractAuthors() \\\{
     1943  var res;
     1944  a = AuthorField.outerText.split(";");
     1945  resolver = a[0]+"&q=";
     1946  b = a[1].split("+%3b+");
     1947  c = a[2].split("\_");
     1948  res = "";
     1949  for (i = 0; i &lt; b.length ;i++)
     1950    \\{
     1951       res = res + "&lt;a href=" + resolver + b[i]+ "&h=dd0&t=0&gt;" + c[i] + "&lt;/a&gt;&lt;br/&gt;";
     1952    \\}
     1953  AuthorField.outerHTML = res;
     1954\\}
     1955\}
     1956</pre></tt></small>
     1957This Javascript function evaluates the string of the defined label, splits it into several strings and composes a string out of thoses values, which is then set to the "outerHTML" element of the label. "&h=dd0" indicates which index to search in, and dd0 should be replaced with the name of the appropriate index. The file gsdl/collect/&lt;collname&gt;/index/build.cfg gives the names of the various indexes.
     1958                 
     1959}
     1960
    18971961#######################################################################
    18981962
Note: See TracChangeset for help on using the changeset viewer.