User Tools

Site Tools


g2:howto

This is an old revision of the document!


G2 HOWTO. Or "How do I ..."

How do I create an alphabar unlike the predefined block ?

Context

The predefined alphabar block provides a standard form alphabar, listing all initials in the alphabar setting with a link to the page for each initial. The block configuration page allows setting of both the alphabar and line-length wrapping.

However I does not allow for bar where, for instance, some initials would be merged (like grouping the numbers together under “#”, for instance).

Solution

The trick is not to use the predefined block, but to create a custom block using the function supplying the predefined block with data: _g2_alphabar(), which returns the current list of initials. With the result of this function, it is possible to visually build the bar to your wished, while retaining dynamic compliance with the actual alphabar contents.

How do I create a constant text linking to a random definition ?

Context

The predefined “random” entry block creates a block listing one pseudo-random entry from the G2 glossary, with a link to its definition page.

However, for some layouts, one can wish to have the blocks not display the entry, but a link with a constant text like “Random glossary definition” linking to a random definition from the G2 glossary.

Solution

The trick is not to use the predefined block, but to create a custom block using the function supplying the predefined block with data: _g2_random(), which returns data for a pseudo-random entry. With the result of this function, it is possible to create the link you want and format it just as you wish.

g2/howto.1135621121.txt.gz · Last modified: 2020/11/23 17:23 (external edit)