Le 25/03/2010 21:58, Chris G a écrit :
Is there any way in DokuWiki to display a link if the link exists but otherwise just display some text? E.g. I have an internal link like:- [[ns1:ns2:page|title]] ... and if ns1:ns2:page doesn't exist I just want 'title' to be shown without any indication that it's anything other than normal text. I suppose I could do this with some CSS changes but I want this change to be optional with the normal default action of red clickable links for non-existent pages to remain on most of the Wiki.
I have a way to get this done, might not be the best but it works ...You have to install the condition plugin (http://www.dokuwiki.org/plugin:condition)
Then create a file in your template directory (DOKU_INC/lib/tpl/<your_tpl>/) named "condition_plugin_custom_tester.php" and paste the folowing code in it :
<?php include_once(DOKU_PLUGIN.'condition/base_tester.php'); class condition_plugin_custom_tester extends condition_plugin_base_tester { function test_page_exists($b, &$bug, $lop=false) {if($lop) return array('\='); // list of accepted test operators, pcre style regexp
// Here we accept test operators : : switch($b['test']) { case '=' : return page_exists($b['value']); default : $bug = true; return false; } } } Then you can use in your pages : <if page_exists=ns1:ns2:page>[[ns1:ns2;page|title]]<else>title</if> Etienne -- DokuWiki mailing list - more info at http://www.dokuwiki.org/mailinglist