Not logged in. · Lost password · Register
Forum: General Help and Support General Stuff RSS
Adding a button to the toolbar
Avatar
bashiralnoimi #1
Member since Feb 2007 · 8 posts · Location: Aleppo, Syria
Group memberships: Local Moderators, Members
Show profile · Link to this post
Subject: Adding a button to the toolbar
I've read this page well, but i couldn't add mt button. I took these steps for adding my own button:

1) created conf/userscript.js file
2) added this code to it:
  1. function add_discussion(){
  2. if(toolbar){
  3.  
  4.   toolbar[toolbar.length] = {"type":"format",
  5.                              "title":"add discussion",
  6.                              "icon":"discussion.png",
  7.                              "key":"",
  8.                              "open":"~~DISCUSSION~~",
  9.                              "close":""};
  10. }
  11. }


I tried to modify inc/toolbar.php by myself, but i didn't get any changes in the toolbar items
  1.  
  2.             'type'   => 'format',
  3.             'title'  => 'add discussion',
  4.             'icon'   => 'discussion.png',
  5.              'open'   => '~~DISCUSSION~~',
  6.             'close'  => '',
  7.             ),
Best Regards تحياتي
Muhammad Bashir Al-Noimi محمد بشير النعيمي

My Blog مدونتي
http://www.hali-sy.com/
This post was edited on 2007-02-18, 10:02 by andi.
Edit reason: fixed formatting
Avatar
zyberdog #2
Member since Oct 2006 · 25 posts · Location: Denmark
Group memberships: Members
Show profile · Link to this post
From what I can understand of the toolbar framework, you are trying two different approaches at the same time. Adding something to the end (javascript) and inserting a button in the existing lineup (toolbar.php).

I suggest you try the following;

1. Remove your modification to inc/toolbar.php
2. Remove the surrounding function tags on your javascript. You don't appear to be calling this function anywhere, so I don't see how it would get added with the function tags around it.

To sum up (conf/userscript.js):
if(toolbar){
  toolbar[toolbar.length] = {"type":"format",
                             "title":"add discussion",
                             "icon":"discussion.png",
                             "key":"",
                             "open":"~~DISCUSSION~~",
                             "close":""};
  }
}
Avatar
aha #3
Member since Aug 2016 · 1 post
Group memberships: Members
Show profile · Link to this post
Hey,

I too want to add a button to the toolbar but have some difficulties with it.
fyi: I just started to work with Dokuwiki, so I just installed it on my localhost to use it as a playground. oh and no, I know nothing about php so please be forgiving with me
Yesterday I tried to add a new button to the toolbar for a new line
array(
                'type'   => 'insert',
                'title'  => 'newline',
                'icon'   => 'newline.png',
                'insert' => '\\ \n',
                'block'  => true
                ),
When I tried it out on my Dokuwiki it only gave out one backslash and the line break (\n), can someone detect why it won't give out both?

Second problem: Since this wasn't working I changed the '\\ \n' to 'asdf' to see if it's working, it didn't gave out asdf yesterday, so I gave up on it. Today, I changed the 'asdf' again to a '\\' guess what happens when I click on the button now – it types asdf instead of the '\\' that are in the array, I just checked it again to see if it actually is there and I didn't forget to save it. I cleared the cache, it still gives out 'asdf'.

It would be awesome if someone could help me with this ridiculous problem.
aha
Avatar
DylanLevy #4
Member since Jan 2017 · 1 post
Group memberships: Members
Show profile · Link to this post
Thanks for helping. this query worked for me. I was facing the problem from two days. Now my problem is resolved. Thanks again.
Avatar
turnermm (Moderator) #5
Member since Oct 2009 · 4762 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #3
The reason you get a result on the following day is a caching feature.  See https://www.dokuwiki.org/devel:toolbar#tips.  Clear both the browser and the dokuwiki caches.

As for the failure to output a double backslash, you need four:
    'insert' =>' \\\\ \n',

In Javscript the backslash is treated as the escape character.  So this '\\' says print one backslash, that is, treat the second backslash as a literal character and not as the escape character.  If you type one backslash you will get a blank result.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
This post was edited on 2017-01-08, 05:48 by turnermm.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2020-01-27, 19:31:30 (UTC +01:00)