Macros in GeneWeb

From GeneWeb
Jump to: navigation, search
150px-Geographylogo svg.png Language: English • français

GeneWeb template files and text captures in notes are not pure HTML and may contain variables

Some historically called macros. These are letters prefixed by %, for instance %s or %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 [ and ] 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.

Les variables encadrées par des crochets ouvrants et fermants [ et ] (et non %) sont traduites par GeneWeb à partir d'un lexique. La page correspondante détaille ce fonctionnement.

Description of the macros

Base

  • %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: gwd.exe
  • %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 ; (ex: gwd.exe?b=toto;)
  • %s : value of "%f" followed by a question-mark ? and the contextual variables (see below) (ex: toto?lang=it;iz=8233;)

Numbers

  • %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

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 wizard_just_friend in a.gwf
  • 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
    Examples:
    display some text if a search by nobility title is active:  : %It...%E
    display some text if visitor is not "wizard" nor "friend":  : %I&NwNf...%E

Various

  • %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 base.gwf.
  • %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 "]".

Contextual variables

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.

  • lang
  • templ
  • 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 <body%b>
  • %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.

See the experts section for a complete list of macros.


GeneWeb Manual

Rembrandt Old Man Reading a Book.jpg

Use and manage genealogical databases

Technical annex