Difference between revisions of "expert"

From GeneWeb
Jump to: navigation, search
m (A2 moved page Expert to expert: minuscule)
m (Variables (evar and bvar))
Line 503: Line 503:
  var_henri=<a href="http://site/base?p=Firstname;n=lastname">First_name Lastname</a>
  var_henri=<a href="http://site/base?p=Firstname;n=lastname">First_name Lastname</a>
(no %x or %macro; in the value of the parameter!!).
(no %x or %macro; in the value of the parameter!!).
== Building trees through direct url construction ==
See [[trees]] or [[trees/fr]]

Revision as of 08:06, 9 June 2016

150px-Geographylogo svg.png Language: English

Template programming (%if; ... %end;)

The template mechanism provides a very powerful mechanism to construct HTML (or other) pages according to the content of a GeneWeb base. This section is not intending to give an exhaustive description of the corresponding language. Through some examples extracted from gw/etc/perso.txt, it provides a glimpse of the possibility. The last two examples are extracted from a template that generates LaTeX rather than HTML.

For further analysis, explore the various other template files, and on last resort, explore the Ocaml source files!!

     %if;has_qualifiers;%public_name; %qualifier;
     %else;%public_name; %surname;%end;
     %if;has_qualifiers;%first_name; %qualifier;
     %else;%first_name; %surname;%end;
%define;married_to(sexx, date_place)
 %if;(sexx = 0 or sexx = 2)
   %if;are_married;[*married%t to:::date_place]0%nn;
   %elseif;are_not_married;[*relationship%t to:::date_place]0%nn;
   %elseif;are_engaged;[*engaged%t to:::date_place]0%nn;
   %elseif;is_no_sexes_check;[*relationship%t to:::date_place]0%nn;
   %elseif;is_no_mention;date_place [*with]%nn;
   %if;are_married;[*married%t to:::date_place]1%nn;
   %elseif;are_not_married;[*relationship%t to:::date_place]1%nn;
   %elseif;are_engaged;[*engaged%t to:::date_place]1%nn;
   %elseif;is_no_sexes_check;[*relationship%t to:::date_place]1%nn;
   %elseif;is_no_mention;date_place [*with]%nn;
%if;(bvar.can_send_image != "no" and image = "" and first_name != "?" and surname != "?")
     <li><a href="%prefix;m=SND_IMAGE;i=%index;" class="add_portrait">
            %if;(auto_image_file_name != "")[*modify picture]%else;[*add picture]%end;
%define;hgindex(alxx, snxx, fnxx, occxx)
  %if;(alxx = "0")
    %if;(occxx = "0")
      \index{snxx, fnxx}
      \index{snxx, fnxx (occxx)}
    %if;(occxx = "0")
      \index{alxx, voir snxx, fnxx}
      \index{alxx, voir snxx, fnxx (occxx)}
    {\it {\bf %alias;}}%apply;hgindex(alias, surname, first_name, occ)\\%nl;

This list does not claim to be exhaustive (but pretty close!!).


Macros (%x)

See Macros for a description of their use.

Below is the result of calling all 26 lower case possible macros: This table is automatically generated by inserting a bit of HTML/GeneWeb code into the notes of one person in your base. The corresponding code is here

Table of GeneWeb macros.

Commands (m=XXX)

List of the commands appearing in URL with the form:


This list does not claim to be exhaustive, and does not "explain" what each command does!

"DOC" (* obsolete *)
"MOD_WDOC"  (* obsolete *)
"MOD_WDOC_OK"  (* obsolete *)
"PS" P
"WDOC" (* obsolete *)

Variables (evar and bvar)

GeneWeb proposed a general purpose mechanism allowing the user/programmer to extend at will the notion of variable described here.

If a new variable is defined in the .gwf configuration file, then it will be possible to test for the value of this variable in the context of a template file. For instance, if we have added


in .gwf, then the following code in the template will be able to perform some specific action:

%if; (bvar.new_var = "sometext" ) 
    ... perform some specific action ...

Similarly, if we have added a new variable in the URL of the query to GeneWeb (localhost:2317/base?p=first-name;n=last-name;lang=fr;tree=3, then it is possible to test for this variable with code such as:

%if; (evar.tree = 3 ) 
    ... display 3 generation tree ...

The value itself of such variables can be inserted in the body of a template by typing %evar.tree;, for instance:

<title>Tree with %evar.tree; generations</title>

The special variable var is treated in the following fashion within notes, sources and comments: If you define in the .gwf file a variable {{{1}}}, then invoquing the macro %vtext; in a note or a template will produce the text some_text as in the following example:

var_who=Bond, James Bond

"My name is %vwho;." in a note will be transformed into "My name is Bond, James Bond.".

This feature is used by some to facilitate signature of sources. The .gwf file contains a list of var_nickname definitions whose value is a full name and possibly a pointer to a page containing more detailed information:

var_henri=<a href="http://site/base?p=Firstname;n=lastname">First_name Lastname</a>

(no %x or %macro; in the value of the parameter!!).

Building trees through direct url construction

See trees or trees/fr

GeneWeb Manual

Rembrandt Old Man Reading a Book.jpg

Use and manage genealogical databases

Technical annex