.. contents:: Contents .. section-numbering:: ----------------- About This Rule ----------------- +--------------------+-------------------------------------+ |**Name** |wikilink | +====================+=====================================+ |**Type** |inline | +--------------------+-------------------------------------+ |**Syntax** normal |``AnyPageName`` | +--------------------+-------------------------------------+ |**Syntax** described|``[AnyPageName displayed link text]``| +--------------------+-------------------------------------+ -------------------------- Parse Configuration Keys -------------------------- None. --------------------------- Render Configuration Keys --------------------------- +----------+--------+--------+-------------------------------------------------------+ |**Format**|**Key** |**Type**|**Description** | +==========+========+========+=======================================================+ |Xhtml |pages |array |A sequential array of page names that exist in the wiki| +----------+--------+--------+-------------------------------------------------------+ |Xhtml |view_url|string |The base URL to view pages in the wiki | +----------+--------+--------+-------------------------------------------------------+ |Xhtml |new_url |string |The base URL to create new pages in the wiki | +----------+--------+--------+-------------------------------------------------------+ |Xhtml |new_text|string |The text displayed after non-existent page names | +----------+--------+--------+-------------------------------------------------------+ ------------- Description ------------- As you should know by now, page names in wikis are made of WordsSmashedTogether in StudlyCapsMode. The wikilink rule looks for WikiPages and creates links out of them. This requires some moderate configuration to customize it for your environment. In Text_Wiki, wiki words are allowed to have numbers in them; each digit 0-9 is treated as a lower-case character for purposes of parsing words. The rule needs to know what pages exist in the wiki, so that when it finds a page name in the source text, it can show the proper link (either to view an existing page, or create a page that has been named but does not yet exist). To tell Text_Wiki what wiki pages exist, use the 'pages' key in `setRenderConf()`_. .. _`setRenderConf()`: https://wiki.horde.org/MethodSetRenderConf?referrer=RuleWikilink :: // [snip] create a Text_Wiki object called $wiki // get the list of pages in the wiki $pages = array( 'HomePage', 'WordsSmashedTogether', 'SomeOtherPages' ); $wiki->setRenderConf('xhtml', 'wikilink', 'pages', $pages); Now Text_Wiki needs to know where to link pages to. There are two configuration keys for this, 'view_url' and 'new_url'. If the parser finds a page name that exists in the 'pages' array, it will use 'view_url'; if the page is not in the 'pages' array, it will use 'new_url'. :: $wiki->setRenderConf('xhtml', 'wikilink', 'view_url', 'http://example.php/view.php?page=%s'); $wiki->setRenderConf('xhtml', 'wikilink', 'new_url', 'http://example.php/new.php?page=%s'); **Note:** Note the use of %s in the above URL strings; the %s will be replaced by the page name. If you specify a string that does not have a %s in it, Text_Wiki will assume that the page name should go at the very end of the string. Finally, if the page exists, Text_Wiki will make the page name itself a link. If the page does not exist, Text_Wiki will add some text after the page name and make that clickable instead (leading to the 'new_url'). Normally the 'new_text' is just a question mark, but you can place any literal text you like.:: // make the new_text a tilde $wiki->setRenderConf('xhtml', 'wikilink', 'new_text', '~'); // make the new_text an image tag $wiki->setRenderConf('xhtml', 'wikilink', 'new_text', '');