Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Compatible with DokuWiki
A plugin for adding custom buttons to the toolbar, to shortcut commonly used code blocks. The latest version has a user-friendly back-end that lets you add two types of shortcut buttons:
<file bash bash.sh></file>
Note: Icon by Joseph North!
Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.
To add some button you should login as admin and click to the “Admin Button”.
Shortcut button for a commonly used URL
Shortcut button for adding a bash script
Deleting
Just click at a radio button and then click “Delete”.
Using the buttons
After you have successfully inserted some buttons you should be able to see them at the edit toolbar, as shown below.
Multiline Codes
If you want to have a shortcut for a common used multiline template (eg. a table) you can use “\n” in the code field to denote the line change.
Example:
Label: 3x3 Table Code: ^ header1 ^ header2 ^ header3 ^\n| valueA1 | valueA2 | valueA3 |\n| valueB1 | valueB2 | valueB3 |
Some dokuwiki releases resize icons to 16×16 size. Just comment the width resizing in /lib/scripts/edit.js (around line 40)
... // create the icon and add it to the button $ico.attr('src', icon); //Disable resizing icons // $ico.attr('width', 16); $ico.attr('height', 16); $btn.append($ico); ...
If you use a dokuwiki template (like vector for example) including “user.js” file, copy the function who manages toolbar button from “edit.js” dokuwiki file and disable icon localy in the user.js file. Do not forget to activate the template option “user-script overwrite”.
Hello,
When setting up the custom button to insert code, it does not work when using the button. Instead of inserting code field, it inserts label field.
Regards.
— The Guy 2015-02-13 10:42
Having “Custombuttons 2014-12-10” and “indexmenu 2014-11-24” on DW 2012-01-25b “Angua” results in “Navigation tree is not displayed” issue (the_tree_is_not_displayed).
— mubedmubed
2015-01-08 17:41
It would be great to have a placeholder symbol for the selected text, e.g “&&” or “$$”. This has two benefits:
[[http://mysearch.com?s=&&|Search result for "&&"]]
It would be great to be able to insert other data as well, eg dates, username etc
eg I have a button that inserts
<todo startdate:yyyy-mm-dd @user>//my text here//</todo>
I'd like to be able to have custom button fill in information such as the date, time and username (or any other info calculated from that eg:
<todo startdate:@Date@ due:@date@+10 @@user@>Update AVG boot disk</todo>
would show as
<todo startdate:2015-02-25 due:2105-03-07 @Chris>Update AVG boot disk</todo>
To achieve the above date substitutions edit your action.php file in the plugin folder to include these additional lines:
protected function loadCBData() { $json = new JSON(JSON_LOOSE_TYPE); $file = @file_get_contents(DOKU_PLUGIN . "custombuttons/config.json"); if(!$file) return false; /** Start of new lines */ $file = str_replace('@@TODAY@@',date("Y-m-d"),$file); $file = str_replace('@@USER@@',$client,$file); $file = str_replace('@@ONEWEEK@@',date("Y-m-d",strtotime('+7 days')),$file); $file = str_replace('@@TWOWEEKS@@',date("Y-m-d",strtotime('+14 days')),$file); $file = str_replace('@@THREEWEEKS@@',date("Y-m-d",strtotime('+21 days')),$file); $file = str_replace('@@FOURWEEKS@@' ,date("Y-m-d",strtotime('+28 days')),$file); $file = str_replace('@@ONEMONTH@@',date("Y-m-d",strtotime('+30 days')),$file); /** End of new lines */ return $json->decode($file); }
I'm still working on getting the username substituted in… If I'd known it was this simple I'd have done it ages ago. The placeholders to put in your button text are @@TODAY@@, @@ONEWEEK@@ etc. Hopefully its obvious enough to make your own tweaks.
A simple button, next to “Delete Selected”, which gives the possibility to change the fields of an existing button.
— Torpedo 2015/05/25 22:36
A great improvment would be to give the ability for every users (not only the admin) to create their own buttons.