6.0.0-git
2020-01-19

Diff for RuleWikilink between 1 and 2

+ {{wikilink}}

[[toc]]

++ About This Rule

|| **Name**   || wikilink ||
|| **Type**   || inline || 
|| **Syntax** normal || {{``AnyPageName``}} ||
|| **Syntax** described || {{``[AnyPageName displayed link text]``}} ||

++ Parse Configuration ValuesKeys

None.

++ Render Configuration Keys

|| **Name** ||**Format** || **Key** || **Type** || **Description** ||
||||
|| {{Xhtml}} || {{pages}} || array || A sequential array of page names that exist in thein the wiki ||||
|| {{view_url}} || string{{Xhtml}} || {{view_url}} || string || The base URL to view pages inpages in the wiki ||||
|| {{new_url}}{{Xhtml}} || string{{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.

TheIn 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 {{setRuleConf()}}.{{[MethodSetRenderConf setRenderConf()]}}.

<php><code type="php">
// [snip] create a Text_Wiki object called $wiki

// get the list of pages in the wiki
$pages = array(
    'HomePage',
    'WordsSmashedTogether',
    'SomeOtherPages'
);

$wiki->setRuleConf('wikilink',
$wiki->setRenderConf('xhtml', 'wikilink', 'pages', $pages);
</php>
</code>

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'.

<php>
$wiki->setRuleConf('wikilink',<code type="php">
$wiki->setRenderConf('xhtml', 'wikilink', 'view_url', 'http://example.php/view.php?page=');
$wiki->setRuleConf('wikilink',
	'http://example.php/view.php?page=%s');
	
$wiki->setRenderConf('xhtml', 'wikilink', 'new_url', 'http://example.php/new.php?page=');
</php>

Finally, if
	'http://example.php/new.php?page=%s');
</code>

> **Note:** Note the page exists, Text_Wiki will make the page name itselfuse of %s in the above URL strings; the %s will be replaced by the page name.  If you specify a link.  If the pagestring that does not exist,have a %s in it, Text_Wiki will add some text afterassume that the page name and make that clickable instead (leading toshould go at the very end of the 'new_url').  Normally the 'new_text' is just a question mark, but you can place any literal text you like.string.

<php>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.

<code type="php">
// make the new_text a tilde
$wiki->setRuleConf('wikilink',$wiki->setRenderConf('xhtml', 'wikilink', 'new_text', '~');

// make the new_text an image tag
$wiki->setRuleConf('wikilink',$wiki->setRenderConf('xhtml', 'wikilink', 'new_text', '<img
	'<img src="new_page.jpg" />');
</php>

</code>