DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:fckg:discussion

Based on the code in above box, I added an additional 'DW Edit' button to the new default template by modifying main.php as shown below. This works well with the CKG editor I use in Binky. - JohnG

WAS

...
// the page tools can be amended through a custom plugin hook
$evt = new Doku_Event('TEMPLATE_PAGETOOLS_DISPLAY', $data);
if($evt->advise_before()){
    foreach($evt->data['items'] as $k => $html) echo $html;
}
$evt->advise_after();
unset($data);
unset($evt);
...

IS

...
// the page tools can be amended through a custom plugin hook
$evt = new Doku_Event('TEMPLATE_PAGETOOLS_DISPLAY', $data);
// Start - DWEdit link
echo '<li><a href="doku.php?id='. $ID . '&do=edit&mode=dwiki&fck_preview_mode=nil" ' .
  'class="action edit" rel="nofollow" title="DW Edit"><span>DW Edit</span></a></li>';
// End - DWEdit link
if($evt->advise_before()){
    foreach($evt->data['items'] as $k => $html) echo $html;
}
$evt->advise_after();
unset($data);
unset($evt);
...

Because a new event is created here, you should create an action plugin that hooks into this event. That would make the action link portable, that is, it would survive upgrades. The basics would look like this:

function register(&$controller) {            
   $controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'dwedit_action_link');
}
 
 function dwedit_action_link(&$event, $param) { 
 if(!$_SERVER['REMOTE_USER']) return;
 global $ID;
 $event->data['items']['dw_edit'] = '<li><a href="doku.php?id='. $ID . '&do=edit&mode=dwiki&fck_preview_mode=nil" ' .
  'class="action edit" rel="nofollow" title="DW Edit"><span>DW Edit</span></a></li>';
 }
plugin/fckg/discussion.txt · Last modified: 2014-04-12 20:34 by turnermm