Hey,
Im new to docuwiki plugin development so i maybe miss something here that i should have known.
I want to change something on a page when the plugin detects my specialpattern {{ninews>}} but for some reason it doesnt work. I probably miss some fundamental of docuwiki plugin writing or even php.
Here my code it should detect {{ninews>testlol}} and write Hello Test1. I tried var_dump the $datatest_conf and this is what i get back: array(3) { [0]=> string(18) "{{ninews>testlol}}" [1]=> int(5) [2]=> int(35) }
Thanks for help
Best regards
Nils
class syntax_plugin_dokuwikinewsplugin extends \dokuwiki\Extension\SyntaxPlugin
{
/** @inheritDoc */
public function getType()
{
return 'substition';
}
/** @inheritDoc */
//function getPType(){ return 'block';}
/** @inheritDoc */
public function getSort()
{
return 32;
}
/** @inheritDoc */
public function connectTo($mode)
{
$this->Lexer->addSpecialPattern('\{\{ninews>[^}]*\}\}', $mode, 'plugin_dokuwikinewsplugin');
}
/** @inheritDoc */
public function handle($match, $state, $pos, Doku_Handler $handler)
{
// {{ninews>testlol}}
$match = substr($match,strlen('{{ninews>'), -2); //Gets the string after >
$data = array();
$params = $match;
// //Default Value
$datatest_conf = array();
$datatest_conf['param'] = $params;
if (!$params) {
msg('Syntax detected but unknown parameter was attached.', -1);
}
else {
return $datatest_conf;
}
}
/** @inheritDoc */
public function render($mode, Doku_Renderer $renderer, $datatest_conf)
{
if($mode == 'xhtml'){
if ($datatest_conf['param']==="testlol") {
$renderer->doc .= "Hello Test1";
}
return true;
}
return false;
}
}
Edit:
Solved it i needed to create a new page so the handle() gets refreshed