Basic syntax:
{{actionlink>[action]|[title]}}
Where action can be one of this (after inc/template.php):
The title element is optional. It lets you specify a custom string to be used instead of the default 'Edit this page', 'Old revisions', 'Recent changes', etc.
For example, syntax like this:
You can easily {{actionlink>edit|customise}} this page.
Will produce an output like this: 'You can easily customise this page', where 'customise' is a link to the 'Edit page' page.
Syntax like this:
{{actionlink>edit}}
Will simply create a 'Edit this page' link.
You can install this plugin using the plugin manager.
Sources: plugin-actionlink-2005-05-26.tar.gz(2kb) | plugin-actionlink-2005-05-26.zip(2kb)
To install manually: create a folder actionlink in lib/plugins and put the code below in syntax.php.
<?php /** * Action link plugin. Lets you use action links in your wiki syntax. * Based on the core function - tpl_actionlink(). * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr <andi@splitbrain.org> * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> * @author nowotny <nowotnypl@gmail.com> */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); class syntax_plugin_actionlink extends DokuWiki_Syntax_Plugin { function getInfo(){ return array( 'author' => 'nowotny', 'email' => 'nowotnypl@gmail.com', 'date' => '2006-05-26', 'name' => 'Actionlink plugin', 'desc' => 'Actionlink plugin lets you use action links in your wiki syntax. Basic syntax: {{actionlink>action|title}}', 'url' => 'http://www.dokuwiki.org/plugin:actionlink', ); } function getType(){ return 'substition'; } function getSort(){ return 306; } function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{actionlink>.+?\}\}',$mode,'plugin_actionlink'); } function handle($match, $state, $pos, &$handler){ $match = substr($match,13, -2); $matches=explode('|', $match, 2); return array('action'=>hsc($matches[0]),'title'=>hsc($matches[1])); } function render($mode, &$renderer, $data){ if($mode == 'xhtml'){ if(!empty($data['action'])) $action=$data['action']; else $action=''; if(!empty($data['title'])) $title=$data['title']; global $ID; global $INFO; global $REV; global $ACT; global $conf; global $lang; global $auth; switch($action){ case 'edit': #most complicated type - we need to decide on current action if($ACT == 'show' || $ACT == 'search'){ if($INFO['writable']){ if($INFO['exists']){ if(!isset($title)) $title=$lang['btn_edit']; $renderer->doc .=$this->tpll_link(wl($ID,'do=edit&rev='.$REV), $title, 'class="action edit" accesskey="e" rel="nofollow"'); }else{ if(!isset($title)) $title=$lang['btn_create']; $renderer->doc .=$this->tpll_link(wl($ID,'do=edit&rev='.$REV), $title, 'class="action create" accesskey="e" rel="nofollow"'); } }else{ if(!isset($title)) $title=$lang['btn_source']; $renderer->doc .=$this->tpll_link(wl($ID,'do=edit&rev='.$REV), $title, 'class="action source" accesskey="v" rel="nofollow"'); } }else{ if(!isset($title)) $title=$lang['btn_show']; $renderer->doc .=$this->tpll_link(wl($ID,'do=show'), $title, 'class="action show" accesskey="v" rel="nofollow"'); } return true; case 'history': if(!isset($title)) $title=$lang['btn_revs']; $renderer->doc .=$this->tpll_link(wl($ID,'do=revisions'),$title,'class="action revisions" accesskey="o"'); return true; case 'recent': if(!isset($title)) $title=$lang['btn_recent']; $renderer->doc .=$this->tpll_link(wl($ID,'do=recent'),$title,'class="action recent" accesskey="r"'); return true; case 'index': if(!isset($title)) $title=$lang['btn_index']; $renderer->doc .=$this->tpll_link(wl($ID,'do=index'),$title,'class="action index" accesskey="x"'); return true; case 'top': if(!isset($title)) $title=$lang['btn_top']; $renderer->doc .= '<a href="#dokuwiki__top" class="action top" accesskey="x">'.$title.'</a>'; return true; case 'back': if ($ID = tpl_getparent($ID)) { if(!isset($title)) $title=$lang['btn_back']; $renderer->doc .=$this->tpll_link(wl($ID,'do=show'),$title,'class="action back" accesskey="b"'); return true; } return false; case 'login': if($conf['useacl']){ if($_SERVER['REMOTE_USER']){ if(!isset($title)) $title=$lang['btn_logout']; $renderer->doc .=$this->tpll_link(wl($ID,'do=logout'),$title,'class="action logout"'); }else{ if(!isset($title)) $title=$lang['btn_login']; $renderer->doc .=$this->tpll_link(wl($ID,'do=login'),$title,'class="action logout"'); } return true; } return false; case 'admin': if($INFO['perm'] == AUTH_ADMIN){ if(!isset($title)) $title=$lang['btn_admin']; $renderer->doc .=$this->tpll_link(wl($ID,'do=admin'),$title,'class="action admin"'); return true; } return false; case 'backlink': if(!isset($title)) $title=$lang['btn_backlink']; $renderer->doc .=$this->tpll_link(wl($ID,'do=backlink'),$title, 'class="action backlink"'); return true; default: if(!isset($title)) $title=''; $renderer->doc .= $title; return true; } } return false; } function tpll_link($url,$name,$more=''){ $link='<a href="'.$url.'" '; if ($more) $link.=' '.$more; $link.=">$name</a>"; return $link; } } //Setup VIM: ex: et ts=4 enc=utf-8 :
This is my first DokuWiki plugin ever, so please, be gentle
— nowotny 2006-05-26
Wouldn't it be easier to call tpl_actionlink and capture the output?
e.g.ob_start(); tpl_actionlink(...); $renderer->doc .= ob_get_clean();— Christopher Smith 2006-05-26 15:54
Probably… but you wouldn't be able to change the 'title'(caption…? whatever you call it…). — nowotny 2006-05-26 19:17
Fair enough. There are a couple of ways you could do it, but point taken.— Christopher Smith 2006-05-28 14:28
You can (now? or always possible?) set the linktext via the tpl_actionlink-function. Exchange the following code with the original render-function an you benefit to all changes in the tpl_actionlink function
function render($mode, &$renderer, $data) { if($mode == 'xhtml') { if(!empty($data['title'])) $title=$data['title']; if(!empty($data['action'])) { $action=$data['action']; } else { if(!isset($title)) $title=''; $renderer->doc .= $title; return true; } if(isset($title)) { ob_start(); tpl_actionlink($action,'','',$title); $renderer->doc .= ob_get_clean(); } else { ob_start(); tpl_actionlink($action); $renderer->doc .= ob_get_clean(); } return true; } return false; }
— Silbär 2008-05-06 15:34
I'm new to all this, but what would the syntax be when changing the tpl_actionlink function code? — Randy 2008-12-14
The feed.php page returns a missing function error unless inc/template.php is included at the top of the plugin code, otherwise, great little plugin. Thanks!require_once(DOKU_INC.'inc/template.php');— sunny 2006-08-17
Not sure if this plugin is still maintained but is it possible to add a manual link to the search function in this plugin too?
to add purge, I put following in front of the “default:” fallback:
case 'purge': if(!isset($title)) $title=$lang['btn_purge']; $renderer->doc .=$this->tpll_link(wl($ID,'purge=true'),$title, 'class="action purge"'); return true;
— Hella 2006-10-26
I got a small problem with actionlink>recent (with httaccess rewrite) : it keeps the current page in the URL, resulting in a partial recent changes (it is limited to the current namespace). E.g. on the pagehttp://mydokuwiki.com/namespace/page,{{actionlink>recent}}points tohttp://mydokuwiki.com/namespace/page?do=recent, which show recent changes only for thenamespacenamespace. This also cause the actionlink>index to unwrap the current namespace, but this is less of a problem.
– Fousage
Will this become fixed? Dakkar
Is there any way to implement subscription link with this plugin?. Thanks. Manuel Munoz
When builing actionlinks for 'admin', 'login' etc. dont forget
~~NOCACHE~~
otherwise (ha!) the page will be cached with authentication infos of the last user editing the page.
Maybe other actions depend on not being cached too…
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported