Macros in GeneWeb
|Language:||English • français|
GeneWeb text present in notes are not pure HTML and may contain variables.
Some are historically called macros. These are letters prefixed by
%, for instance
%x. GeneWeb replaces these macros by their values depending on the context of the base: name of the base, language, number of persons in the base, etc...
Other variables, bracketed by
] trigger the translation process of GeneWeb according to the current language, and use for this translation the lexicon data. The lexicon page describes in details this translation process.
Description of the macros
- %t : name of the base
- %f : in server mode (stand alone machine), name of the base, possibly followed by a token (en
toto_xyzzy); in CGI mode the launch command (ex:
- %g : in server mode, same as "%f"; in CGI mode, name of the launch command followed by
?b=, the name of the base and a semi-colon
- %s : value of "%f" followed by a question-mark
?and the contextual variables (see below) (ex:
- %n : number of persons in the base.
- %c : numbers of visits to the welcome page
- %q : number of visits to the site (one page = one visit)
- %d : date of the first visit.
Conditionnals begin by "%I" followed by a boolean expression and terminate with "%E". Text between these two delimiters is displayed only if the boolean expression evaluates as true:
- f : visitor is registered as friend
- w : visitor is registered as wizard
- j : wizard_just_friend has been activated (see
- c : the server is in CGI mode
- h : a modifications history file exists
- l : the web browser does not handle tables
- n : a notes file exists for this base
- t : a search by nobility title has been launched
- z : there exists a sosa reference person (see "%u")
- a : access to the base is globally restricted
- N : negation of what follows
- | : logical "or" between the two following expressions (not e1&e2, but &e1e2!!)
- & : logical "and" between the two following expressions
- display some text if a search by nobility title is active: :
- display some text if visitor is not "wizard" nor "friend": :
- %r followed by text: include a file names text.txt. The file must be at the same location as the file containing the "%r"
- %b : value of the "body_prop" variable found in
- %h : contextual variables (see below), in the form "<input type=hidden name=var value=val>".
- %l : language.
- %u : person taken as sosa reference (i.e. sosa 1)
- %% : a single "%".
- %[ : a single "[".
- %] : a single "]".
Some variables have a lasting influence on GeneWeb across multiple requests. As opposed to the other requests parameters, once activated (by selecting an option through the GUI, or by direct typing in the URL window) the appear in all successive requests unless explicitly removed.
- pz, nz, ocz, iz (first_name, last-name, occurence, index of a sosa reference)
- list to be completed ...
Frequently used macros
- %b typically inserted in the
<body>HTML tag as in
- %s which you will use for any of your href links
Examples in "celebres.txt":
See my cousin <a href="%sp=louis;n=de+bourbon;oc=5"> Louis XIV</a> and my <a href="%sem=R;ep=jean;en=dupont;m=NG;n=louis+xiv;t=PN"> relationship</a> with him.
List of macros
Available macros in the context of
m=SRC files :
This table can be generated by inserting a
m=SRC call to some HTML/GeneWeb code in the note section of somebody in your base. The corresponding code is here
The third column provides the result of execution in a specific context
|Macro||Example use||Result||What it does|
|%a||%a||Displays name of sosa reference (See %Iz below)|
|%b||%b||Value of "body_prop" (in base.gwf)|
|%c||%c||42||Number of queries for the welcome page|
|%d||%d||10 décembre 2018||Date of first visit|
|%D||%D||10/12/2018||Date of first visit|
|%f||%f||HenriT_w||In server mode, base name followed by password. In CGI mode, name of the CGI command (ex: gwd.exe)|
|%g||%g||HenriT_w?||In server mode, same as "f". In CGI mode, name of the command, followed by "?b=basename;"|
|%h||%h||A list of var=value for each hidden url variable|
|%j||%j||Include hed.txt file|
|%k||%k||geneweb?||Value of the action parameter of a http GET/PUT command|
|%L||%L||left||Left (style: used in align="%L")|
|%m||%m||30||Value of latest_event (in base.gwf)|
|%n||%n||8879||Number of persons in the base|
|%N||%N||: titre||Content of base_notes_title (.gwf)|
|%o||%o||images||Value of %image_prefix; (see doc for image_prefix details (to be completed))|
|%q||%q||285||Number of queries|
|%r||%rfile||test for macros||Reads file bases/src/base/test.txt) (file must be followed by "end of line")|
|%R||%R||right||Right (style: used in align="%R")|
|%s||%s||HenriT_w?||Value of %f followed by "?" and contextual variables (ex: "toto?lang=it;iz=8233;")|
Typical use: <a href="%sp=first_name&n=surname">Link to person First_name Surname</a>
|%T||%T||Value of %doctype; (Given that doctype translates into <-- .... -->,|
nothing is visible in the result column. Look at the sources to verify)
|%u||%ufr;||français||returns "Français" if lang=fr, and "French" if lang=en (dont forget the ;)|
|%U||%U||: hg||User name|
|%v||%v||7.00-exp||Returns GeneWeb version number|
|%v||%vtext;||xxxx||Specific to the NOTES context: returns the value of bvar.var_text|
|%V||%Vvar;||oui||Value of bvar.var (in base.gwf) example %Vtest;|
|%w||%w||Link to previous page (with back arrow icon)|
|%X||%Xvar;||macros||Value of evar.var (in URL) example %Xv;|
|%/||%/||if doctype = "html-4.01" then "" else "/" (used to terminate html tags as in <br%/> -> |
|%Ia||%IaYes%E %INaNo%E||No||auth_file exists. Global access restriction is on (see Access)|
|%Ic||%IcYes%E %INcNo%E||No||Cannot handle passwords|
|%If||%IfYes%E %INfNo%E||No||We are "Friend"|
|%Ih||%IhYes%E %INhNo%E||Yes||There is a history file|
|%Ij||%IjYes%E %INjNo%E||No||Wizard_just_friend is active|
|%Il||%IlYes%E %INlNo%E||No||Browser handles tables|
|%Im||%ImYes%E %INmNo%E||Yes||notes_links <> |
|%In||%InYes%E %INnNo%E||Yes||There is a base note file|
|%Io||%IoYes%E %INoNo%E||Yes||Notes dir exists|
|%Ip||%Iptest;Yes%E %INptest;No%E||Yes||Base env variable <> "" (var terminated by ;)|
|%Is||%IsYes%E %INsNo%E||Yes||Base env variable <> "no"|
|%Iw||%IwYes%E %INwNo%E||Yes||We are "Wizard"|
|%Iz||%IzYes%E %INzNo%E||No||Sosa ref exists|
|Expressions are limited to the following macros : a c f j l m n o p s w z which return True or False|
|%It||%ItYes%E %INtNo%E||!!!!!t!!!!!Yes !!!!!t!!!!!||Bad macro (twice) (prints !!!!x!!!!, returns True)|
|%IN||%IN[expression]||Inverts the result of [expression] (See %If thru %Iz for usage examples)|
|%I|||%I|fwfrd or wiz%E||frd or wiz||Logical "or" of the two following expressions ("f" and "w" in the example)|
|%I&||%I&whwizard and history file%E||wizard and history file||Logical "and" with two following expressions ("w" and "h" in the example)|