Re: [greenstone-devel] Reproducing drop down navigation menus in Greenstone

From Angela
DateThu, 14 Jul 2005 11:29:17 -0600
Subject Re: [greenstone-devel] Reproducing drop down navigation menus in Greenstone
In-Reply-To (42D5EC45-2060708-cs-waikato-ac-nz)
Hi Michael,

Thank you for all your help Michael. I tried the fix but it didn't work.
Greenstone doesn't replace the links. I searched through HTMLPlug and I
think this is what's happening (I could be wrong though). HTMLPlug seems to
only check for href and src tags following a, area, frame, link, or script.
I haven't found a place where it would replace any other links.
The code in HTMLPlug's sub process_section:

$$textref =~
$self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj,

The solution I came up with is to add a placeholder (_replacelink_) inside
<option value>:

<form action="" class="changeView" name="view" title="Use this to change the
way the information in this document is displayed."><select name="choices"
tedIndex].value"><option selected="selected"
value="_replacelink_index.htm">Reading text</option><option
value="_replacelink_significant.htm">Significant variants</option><option
value="_replacelink_substantive.htm">Substantive variants</option><option
value="_replacelink_orthographic.htm">Orthographic variants</option><option
value="_replacelink_analytic.htm">All readings (analytic)</option><option
value="_replacelink_parallel.htm">All readings

I changed HTMLPlug to replace links that contain the _replacelink_

$$textref =~ s/(_replacelink_?)([^">s]+)("?[^>]*>)/
$self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj,

# remove _replacelink_ placeholder
$$textref =~ s/_replacelink_//ig;

This is probably not the best way of doing it, but it does seem to work.

Take care,

-----Original Message-----
[]On Behalf Of
Michael Dewsnip
Sent: July 13, 2005 10:38 PM
Subject: Re: [greenstone-devel] Reproducing drop down navigation menus in

Hi Daniel,

Greenstone has code for dealing with relative links in source documents,
so I think you can get the effect you're after by tapping into this.

In a simple case, imagine a Greenstone collection with two documents,
doc1.html and doc2.html, each with a relative link to the other, eg:

<a href="doc2.html>Link to doc2.html</a>

When you build this collection, Greenstone will replace the relative
links with calls to the Greenstone "extlink" action:

<a href="/cgi-bin/library?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-help-Angela--00-0-1-00-0-0-11----0-0-&a=extlink&rl=1&href=http://doc2.html">Link to doc2.html</a>

This means that when you're browsing the built collection and click on
the link, Greenstone will redirect you to the appropriate document.

In your case, you need to extend the option values to have the full
relative paths, since the value must uniquely identify a document:

<option value="http://foldername/substantive.htm">Substantive

When your users select one of these options, loading
"/cgi-bin/library?a=extlink&rl=1&href=[value]" should take you to the correct

Hope this helps,


Daniel Paul O'Donnell wrote:

> I've gone through the archives and documentation, and while I can
>a number of almost similar examples to this problem, I can't find
>anything that does the crucial thing I need to answer the problem.
>Please excuse me if that's because the answer is so obvious nobody's
>ever asked. I have gone over it with a real expert, though.
> Basically, the issue is that in an HTML document set, I use drop
>menus with javascript to navigate between different "views" of a text.
>There can be as many as 12 different "views" so a list of links is
>inefficient; it also doesn't get the idea across that all 5 to 12
>documents are actually the same text with different features emphasised.
>Here is the code I use in my HTML:
><form action="" class="changeView">
> <select name="choices" size="1"
> <option value="index.htm">Reading text</option>
> <option selected="selected" value="significant.htm">Significant
> <option value="substantive.htm">Substantive variants</option>
> <option value="orthographic.htm">Orthographic variants</option>
> <option value="analytic.htm">All readings (analytic)</option>
> <option value="parallel.htm">All readings (parallel)</option>
> </select>
>The trouble in Greenstone is that these URLs on option@value are not
>converted to hash addresses. It appears that what I need to do is write
>a macro for the Javascript, but I confess I'm not sure how to do it so
>the values are correctly converted to Greenstone hashes (if that's the
>right term). There are a fair number of examples of almost identical
>code in the archives, but none that seem to be used for arbitrary
>addresses like this. Any suggestions?

greenstone-devel mailing list