Re: [greenstone-devel] RE : hyperlink individual metadata elements

From Michael Dewsnip
DateThu, 21 Dec 2006 13:58:06 +1300
Subject Re: [greenstone-devel] RE : hyperlink individual metadata elements
In-Reply-To (A11793301D39D711A6850002A5EF77E108F34BD5-SIVALEXG017)
Hi Patrick,

You need to add a check that the "subject" variable isn't null in the
ExtractSubjects function:

function ExtractSubjects() {
var res;
var subject = document.getElementById("SubjectField");
if (subject != null) {
a = subject.innerHTML.split(":");
resolver = a[0]+"&q=";
b = a[1].split("%3a%5c");
c = a[2].split("_");
res = "";
for (i = 0; i < b.length ;i++)
{
res = res + "<a href=" + resolver + b[i]+ "&fqf=DS&t=1>" + c[i] + "</a> ";
}
subject.innerHTML = res;
}
}


Regards,

Michael

HERNEBRING Patrick wrote:

>Katherine,
>
>Thank you very much ! Every thing is working now...
>
>But, if the subject field is empty, there is a bug on the page...
>
>How to avoid this ?
>
>Regards
>
>Patrick Hernebring
>
>Fonds musical ancien - Nu€risation
>
>Bibliot€que d'Etude et du Patrimoine
>
>Bibliot€que de Toulouse
>
>1 rue de €rigord, 31000 Toulouse
>
>€l : 05 62 27 63 76
>
>
>-----Message d'origine-----
>De : Katherine Don [mailto:kjdon@cs.waikato.ac.nz]
>Envo€ : mercredi 13 €cembre 2006 23:24
€ : HERNEBRING Patrick
>Cc : greenstone-devel@list.scms.waikato.ac.nz
>Objet : Re: hyperlink individual metadata elements
>
>Hi Patrick
>
>I have managed to get this going in my installation. I had to change
>things slightly. Here is what I used:
>
>DocumentHeading:
>{If}{[dc.Subject], <tr><td align=right
>valign=top><b>Sujet(s):</b></td><td align=left valign=top><label
>name=SubjectField
>id=SubjectField>/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&a=q:[cgisafe:sibling(All:':'):dc.Subject]:[sibling(All:'_'):dc.Subject]</label></td></tr>}
>
>The same as yours except I changed the ; separator to :
>
>Macros:
>
>package document
>
># header overridden for text pages
>_textheader_ {
> GSDL Error
>


>
><!-- document:textheader -->
><div id="banner">
><div class="pageinfo"><p class="bannerlinks">HOME HELP PREFERENCES</p></div>
><div class="collectimage">Greenstone Archives collection</div><br></br><br></br><br></br>
><table align="right"><font size="2"><a
>href=/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&cl=search&d=4589DC1E-5050605-cs-waikato-ac-nz&l=fr&w=utf-8>Fra€ais</a> | <a
>href=/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&cl=search&d=4589DC1E-5050605-cs-waikato-ac-nz&l=en&w=utf-8>English</a> | <a
>href=/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&cl=search&d=4589DC1E-5050605-cs-waikato-ac-nz&l=zh&w=utf-8> 中文</a></br></table></font>
></div>
><div class="bannerextra"></div>
>}
>
>### Self-made Javascript functions
>{
>function ExtractSubjects() {
> var res;
> var subject = document.getElementById("SubjectField");
> a = subject.innerHTML.split(":");
> resolver = a[0]+"&q=";
> b = a[1].split("%3a%5c");
> c = a[2].split("_");
> res = "";
> for (i = 0; i < b.length ;i++)
> {
> res = res + "<a href=" + resolver + b[i]+ "&fqf=DS&t=1>" + c[i] +
>"</a> ";
> }
> subject.innerHTML = res;
> }
>}
>
>Changes include the split value for a and b, the way the SubjectField is
>referred to. Don't forget the package name.
>
>My collection is using MGPP, so the query args changed from h=xx&t=0 to
>fqf=xx&t=1. This may not apply to your case.
>
>Hope this helps,
>Regards,
>Katherine
>
>
>HERNEBRING Patrick wrote:
>
>
>>Hi all,
>>
>>I’m trying to apply the Axel Schild’s method to hyperlink individual metadata elements but it isn’t working…
>>Does anybody able to tell me what I’m making wrong…
>>
>>Here is a quote of my DocumentHeading format :
>>
>>{If}{[agt.Subject], <tr><td align=right valign=top><b>Sujet(s) :</b></td><td align=left valign=bottom><label name=SubjectField id=SubjectField>/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&a=q;[cgisafe:sibling(All:' ;'):agt.Subject];[sibling(All:'_'):agt.Subject]</label></td></tr>}
>>
>>Here is a quote of my extra.dm in the macro directory :
>>
>># header overridden for text pages
>>_textheader_ {
>> GSDL Error (onload="ExtractSubjects();")
>><center>
>><table width=537><tr><td align=right>
>>_icontab__javalinks_</td></tr></table>
>></center>
>>

>>
>><!-- document:textheader -->
>><div id="banner">
>><div class="pageinfo"><p class="bannerlinks">HOME HELP PREFERENCES</p></div>
>><div class="collectimage">Greenstone Archives collection</div><br></br><br></br><br></br><table align="right"><font size="2"><a href=/gsdl//gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&cl=search&d=4589DC1E-5050605-cs-waikato-ac-nz&l=fr&w=utf-8>Fra€ais</a> | <a href=/gsdl//gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&cl=search&d=4589DC1E-5050605-cs-waikato-ac-nz&l=en&w=utf-8>English</a> | <a href=/gsdl//gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-about-Michael+Silver--00-0-21-00-0--4----0-0-11-10-0utfZz-8-00&cl=search&d=4589DC1E-5050605-cs-waikato-ac-nz&l=zh&w=utf-8> 中文</a></br></table></font>
>></div>
>><div class="bannerextra"></div>
>>}
>>
>>### Self-made Javascript functions
>>{
>>function ExtractSubjects() {
>> var res;
>> a = SubjectField.outerText.split(";");
>> resolver = a[0]+"&q=";
>> b = a[1].split("+%3b+");
>> c = a[2].split("_");
>> res = "";
>> for (i = 0; i < b.length ;i++)
>> {
>> res = res + "<a href=" + resolver + b[i]+ "&h=da1&t=0>" + c[i] + "</a><br/>";
>> }
>> SubjectField.outerHTML = res;
>> }
>>}
>>
>>Any help or advice is greatly appreciated.
>>
>>
>>Patrick Hernebring
>>
>>Fonds musical ancien - Nu€risation
>>
>>Bibliot€que d'Etude et du Patrimoine
>>
>>Bibliot€que de Toulouse
>>
>>1 rue de €rigord, 31000 Toulouse
>>
>>€l : 05 62 27 63 76
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>greenstone-devel mailing list
>>greenstone-devel@list.scms.waikato.ac.nz
>>https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-devel
>>
>>