[greenstone-users] Classifier macros

From Katherine Don
DateSat Oct 17 21:03:41 2009
Subject [greenstone-users] Classifier macros
In-Reply-To (D6B530A1090A224EA17A37D3BFE35F5E39AEF1E450-XVS2-CLUSTER-yu-yale-edu)
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("CL3.8.10",[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("CL3.8.10");
>
> </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
>