WikkiTikkiTavi supports two breeds of macro: macros that are executed at display time, and macros that are executed at save time.
Display Macros
When present in a page the text of the macro call is replaced with the output of the macro. For more on the gory details see /Documentation. In the list below the first link, using the name of the macro, shows an actual use of the macro. If present the second link, i.e. /WantedPages, gives more documentation on the given macro and what options could be used along with this specific macro.
- !- category macro. See TaviCategories.
- Anchor- create an HTML anchor.
- Transclude, /Transclude - transclude one page's contents within another page.
- PageSize- display a sorted list of the size of all pages.
- LinkTable- display a list of each page and all of the pages it links to.
- OrphanedPages- display a list of which pages have no links to them.
- WantedPages, /WantedPages - display a list of the pages that are linked to but don't yet exist.
- PageLinks- display a list of how many pages each page links to.
- PageRefs- display a list of how many times each page is linked to.
- RefList, /RefList - display the anonymous references used earlier on the page
- TitleSearch, /TitleSearch - shows the result of a search in the page titles. Is here used as an index page.
Save Macros
Some 'Tavi macros are executed at the time you save the page. These macros parse the text of the page and perform some action. The sequence of events is as follows:
- action/save.php locks the page in the database so no-one else can write to it.
- It saves the edited text.
- It then calls template_save. By default this redirects the browser to the just-saved page (you might change this, for example, to display a "thank you" page like WardsWiki does, or even have the template_save function do a spell-check on the text and display words that didn't match).
- It parses the text for save macros. The save macro parsers are found in config variable $SaveMacroEngine.
- Lastly, once the macros have been run, it unlocks the page.
The browser is redirected before the macros are run because the macros will provide no output. This is an attempt to reduce the time-to-view after a page is saved.
- Is this the cause of the "EditedPageDoesntShow"-problem from the TaviFAQ? How can this be solved?
Currently, three on-save macros are part of 'Tavi.
They are:
- parse_define_interwiki
- parse_define_sisterwiki
- parse_define_links.
The first two look for
InterWiki and
SisterWiki syntax, and update the
prefix_interwiki and
prefix_sisterwiki tables accordingly. The last one searches the page for links to other pages, and updates the
prefix_links table. (The 'links' table is used to keep track of which pages link to which other pages, making the job of some of the on-display macros, like
WantedPages, much easier.)
Installation of additional macros
If you found a macro you'd like to install, e.g. one from the TaviPatches, these are generic installation instructions:
- Save the code to a new file, for example one under a new directory macros.
- Add a line to parse/macros.php
require_once('path/to/macro.php');
- Add a new element to the array $ViewMacroEngine in lib/default.php:
'MacroName' => 'view_macro_macroname'
- Use the macro with [[MacroName arguments ...]]
Questions
Q: How do you include macros?
- A: ...
Q: Is there any sort of macro or trick by which we can have our added comments for a page marked with a date/time such as a Journal type entry?
- A: Please see TaviPatches/AutomaticSignature for an idea and rework it as necessary.