[greenstone-users] Classifier macros

From Belanger, Arthur
DateWed Oct 21 04:16:02 2009
Subject [greenstone-users] Classifier macros
In-Reply-To (4AD97AEF-40300-cs-waikato-ac-nz)
Katherine,

Thanks for the response. I was afraid that was the case.

Perhaps if I explain the end result of what I am trying to accomplish, you or someone else may be able to help.

When using a browsing classifier, AZCompactList in my case, a format statement such as [link][Title][/link] ([numleafdocs]) produces something like the following:

Apple (3)
Arugula (5)
Asparagus (1)

Apple, Arugula and Asparagus are links which open a bookshelf (classifier node) containing the documents. When licking Apple, he same format statement produces something like:

Apple (3)
Apple Pie and Ice Cream ()
How to make Apple Cider ()
Varieties of Apples and Their Uses ()

The last 3 lines are links to the actual documents. The empty parentheses indicate that there are no nodes below the document, that is [numleafdocs] does not exist.

The Apple line is a link back to the list, closing the bookshelf. So, the Greenstone server "knows" when to generate the "close bookshelf" link. I would like to be able to detect this myself so I can change the [Title] to something like "Back to Subject list". An {if} statement in my format would look something like this:

{If}{_test-for-closing-bookshelf_,[link]Back to Subject List[/link],[link][title][/link]

Producing:

Back to Subject List
Apple Pie and Ice Cream
How to make Apple Cider
Varieties of Apples and Their Uses

Is there such a test available via a macro or system generated piece of metadata (like [numleafdocs]) that I can use for the test?

I hope this explanation is clearer than my original post.

Thanks very much.

--
Arthur Belanger
Medical Library System Manager
ITS Academic Media & Technology
Yale University
PO Box 208065
New Haven, CT 06520-8065

(203) 785-6928
(203) 737-2859, fax

mailto:Arthur.Belanger@Yale.Edu
http://www.yale.edu/its/about/amt
http://info.med.yale.edu/library


NOTE: Yale ITS will NEVER request passwords or other personal information via email. Messages requesting such information are fraudulent and should be deleted.

-----Original Message-----
From: Katherine Don [mailto:kjdon@cs.waikato.ac.nz]
Sent: Saturday, October 17, 2009 4:06 AM
To: Belanger, Arthur
Cc: greenstone-users@list.scms.waikato.ac.nz
Subject: Re: [greenstone-users] Classifier macros

Hi Arthur

Yes, this will not work. The format statements are processed by the
library program, then the result s output to the page. The browser
handles the javascript, so its done after the library program has
finished. So when the {If} statement is processed, the value of your
_classifierNode_ maco is the javascript code.

Once option is to generate the classifier level macro in C code. I'll
look at adding this in for a future release.

Another option is to do all the output in javascript. Whether this works
will depend on what you want to do.

Can you do something like

function CLLevel (CLstr, level1str, level2str, level3str) {

var level_num = generate the level number
if level_num == 1, output level1str,
else if level_num == 2, output level2 str
etc
}

then in format statement, use a macro like you did before, or just write
the javacsript elements, and CLLevel("search",[dc.Title],[ex.Title])
or whatever.

Hope this is a bit comprehensible,
Katherine

Belanger, Arthur wrote:
>
> Hi.
>
> I am trying to find a way to test in a classifier format statement
> (e.g. CL2Vlist) which level the current node is in. I have used
> [numleafdocs] to determine whether the current node is a document or a
> node but that is insufficient.
>
> The only way that I have figured out thus far is to parse _/cgiargcl/_.
>
> Are there any macros that can be used to tell me where in the
> classifier list the current node is? That is, if _/cgiargcl/_ is
> CL2.3.10, the macro should tell me that I am at level 3 (or 2
> depending on how you count). Similarly, if _/cgiargcl/_ is CL2.3, it
> should return 2 (or 1 dependiong on how you count). I haven't been
> able to identify such a macro.
>
> So, I have written a javascript function to parse _/cgiargcl/_ and
> return the right number but I haven't been able to test against the
> value though I can display the value on the page. I have put the
> script in _/pagescriptextra_ in the collection's extra.dm file. I call
> it in a macro (_Classifiernode/_) but I can't test against it. I am
> not a javascript programmer so I am probably missing something rather
> simple.
>
> Here is the javascript:
>
> function CLfoot(CLstr) {
>
> var classnode = new String(CLstr);
>
> var classifier = classnode.split(".");
>
> document.write (classifier.length);
>
> }
>
> Here is the macro:
>
> _classifierNode_ {
>
> <SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
>
> CLnode("search");
>
> </SCRIPT>
>
> }
>
> My format statement includes:
>
> {if}{_classifierNode_ == 2,Second Level,Third Level)
>
> _classifierNode_
>
> Thus, if _/cgiargdl/_ = CL2.4, _classifierNode should be 2 and "Second
> Level" should be displayed.
>
> If _/cgiargcl/_ = CL2.4.7, _/classifierNode/_ should be 3 and "Third
> Level" should be displayed
>
> The _/classifierNode/_ line does produce the correct number but it is
> not actually the value of the macro.
>
> So, what I would like is to have _classifierNode_ be either 2 or 3 as:
>
> _/classifierNode/_ {2} or _/classifierNode/_ {3}
>
> I suspect that the document.write statement is not the proper way to
> pass a value back and/or Greenstone does not support such dynamically
> generated macros.
>
> Any help would be greatly appreciated. Thanks.
>
> Thanks.
>
> Arthur Belanger
> Medical Library System Manager
> ITS Academic Media & Technology
> Yale University
> PO Box 208065
> New Haven, CT 06520-8065
>
> (203) 785-6928
> (203) 737-2859, fax
>
> mailto:Arthur.Belanger@Yale.Edu
> http://www.yale.edu/its/about/amt
> http://info.med.yale.edu/library
>
> NOTE: Yale ITS will NEVER request passwords or other personal
> information via email. Messages requesting such information are
> fraudulent and should be deleted.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> greenstone-users mailing list
> greenstone-users@list.scms.waikato.ac.nz
> https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-users
>