writting custom button plugins

this is a small guide how to write a plugin for your custom buttons.

for adding your custom button, you must create a regular Movable Type plugin.
but, don't be hesitate, just one yaml file and one picture file, they're all that required to fix up. no perl required.

here we start with creating a button, that put a 'hello' in front of selection. at first, we build a yaml file.

writing yaml

plugin information

write your plugin information in the first section. they will appear in the MT's CMS plugin screen.

name: Hello Button
id: Hello Button
key: HelloButton
author_link: http://blog.aklaswad.com/
author_name: Aklaswad
description: Say hello.
version: 0.1
plugin_link: http://blog.aklaswad.com/mtplugins/hellobutton/

add button section

buttons:
    hello:
        image: hello.png
        title: say hello!
        code: |
            function ceb_hello ( text ) {
                return 'Hello! ' + text;
            }

this block is a definition of each button. you can write multiple buttons definition in the same plugin.

button name

buttons:
    hello:

here is a name difinition.
write your buttons name in the next line of the 'buttons' block head. it must be unique, and the name must have no blank.

image

set path of image file that be used to display this button.

title

a short description for mouse over.

code

write your button's function in JAVASCRIPT.
CustomEditorButton plugin looks for and calls the function that named the button's name with 'ceb_' prefix.
the first argument 'text' includes a string that selected in the editor. almost, we want to do is do something for this 'text' and return it.
your return will be inserted to the editor's selected part.

            function ceb_hello ( text ) {
                return 'Hello! ' + text;
            }

picture

hello.png22px x 22px picture file that can be displayed by the web browser.

if you're too tired to open your photoshop, delete the 'image:' line and insert a 'face_text' with a short text. it will be the button image.

buttons:
    bye:
        face_text: bye
        title: say bye!
        code: |
            function ceb_bye ( text ) {
                return 'bye ' + text;
            }

install

make directory in your MT's plugins directory with the name of your plugin, and save the yaml file with the name 'config.yaml'.
if you have an image, make a same name directory to your mt-static/plugins directory, and put your image file there.

now, let's open your MT and check the system / plugins screen.

hello_pluginconfig.png

yes, it's successed!

...if your plugin was not shown to the list, check your target of upload.
if you got an error message like this;

Got an error: Error reading /home/foo/public_html/cgi-bin/mt/plugins/HelloButton/config.yaml: Stream does not end with newline character (YAML_PARSE_ERR_NO_FINAL_NEWLINE) at lib/MT/Component.pm line 150.

the reason may be a wrong yaml format. check your indent, linefeed code, and the linefeed of the last line(it is required because of yaml's specific).

hello_on_editor.pngwhen you got all green, check MT's editor and your button be appear. maybe your button is in the pocket.

here is a hello button plugin that we finished.

other functions

arguments to the callback

you can use a helper object from the second argument.

function ceb_foo(text, args) {
    //do something
}

some method and property are given from this object.

innerHTML()
return the selection with HTML. different from the 'text' argument, innerHTML will return an HTML though the editor is in iframe mode.
iframe
bool that the editor is on iframe mode.
editor
return a reference of MT.App.editor.

return value of the callback

if you return in your callback, CustomEditorButton do nothing to the editting field.

175 Comments

Great article and plugin aklaswad. Thanks for the help.

Hello, i'd sure imagine that this really along area yet anyhow, as a former checking in the market your website a lot of friends appears to be literally relatively organized. I am thankful for building a newbie blog page as trying to cope capital look good, whenever anyway i come near a person thing simply put i mess it up. Practical ideas on how grueling was the software to improve the sites? Might be able to a loved one just like me with out time spent accomplish this, also add bloodline renovate pages and posts need to have of wrecking keep in mind this exercising?

Greetings, likely this could be separate from market but rather in any event, for a nice and looking through with your blog post that's why it would seem to be highly fully trendy. I am just creating a upcoming net to experiencing struggles so it will be look really good, everytime my own handle few things we all spoil it. Tips about how complicated had been keep in mind this to enhance a web site? Could easily an individual just like me devoid of the practice do it now, and as a consequence incorporate styles revise rankings while not having wrecking this every time?

With these market in the same manner it happens to be, I decided to arrange helpful information for declaring jobless positive effects. Individual indication ended up being show you the fact that jobless procedure is profitable, about the commonplace means accepting and it could be rejecting comments, and after which add in reports ranging from my own diamond ring explore as to what the best approaches plus primary complications are developed in filing joblessness results.

I am planning on utilizing a few Private label rights web content, but I am kind of frightened that Google or bing will see it as duplicate written content and then punish my site. Do you feel I ought to work with it or should I just come up with my own content?

Working as being a nursing assistant isn't a task as simple as it might look before you get into it. You will have to virtually apply all of your information along with skills learned during the degree course. In order to carry out well practically, you should select a nursing school that is affiliated with an equally accredited nursing house, hospital or any other wellness facility where you'll be able to apply your newly discovered abilities daily.

To be a productive nursing assistant, an individual need to be a crew participant who's placement to take orders properly. They need to also be emotionally steady and have a fantastic deal of persistence.

Working as a nursing assistant isn't a task as simple as it could appear just before you obtain into it. You'll need to virtually apply all of your information along with abilities discovered during the diploma program. In order to carry out properly virtually, you must choose a nursing school which can be affiliated with an equally accredited nursing house, hospital as well as any other health facility exactly where it is possible to apply your newly discovered skills each day.

The thought of mechanics educated guess one or more regarding three main Ough.Ise. tradesmen are already mistreated significantly a lot at work which usually the companies overall health is harmful? Which could be Fifty four mil persons! Actually per one particular '07 Zogby Worldwide surveys.

“When a man is wrapped up in himself he makes a pretty small package.” –John Ruskin

Nicely written, its not that usual to read stuff that is worth checking out nowadays :)

I got my first camera when I was 10 and usually have one with me. I am unable to claim I've figured out all the very complicated details that make a high-end image. Nevertheless I am pretty sure I can capture decently almost anything, even an UFO.

It's the post production that is bugging me. I just can't figure out the retouching part. It always seems unnatural in my opinion. People assure me it looks cool but I can't decide whether it's true or just a compliment. The clients are always happy with my creations to be honest but that is nothing new. Choosing the correct equipment is nothing more than simply information mentioned in books. Sometimes despite the fact that I am trying to pay attention I keep getting somewhat bad brightness, unadjusted contrast or exposure. I mix up the settings adjusting the colors sometimes. It can be unbaringly stressing however rant stops at this point.

Wayne's 6'7' track is on fire. Sounds like A Milli but a million times better. Cory tosses in a blazin guest verse with 2x time bars and he proves that he still has the ability that he showed on the remix to A Milli! Wayne destroys his verses as usual. Altogether, 6' 7' is a brilliant collaboration everyone should listen to!

Hi,I not see the picture…you have remove it or is my browser? Thanks. Stefano – Italy

Hi, thanks so much for these tips! My blogs usually do bring readers and responses. One thing I do is engage with the readers. Answer questions in responses and make clarifications where needed. I think they appreciate that I take the time to talk to them.

I don’t even know how I ended up here, but I thought this post was good. I don't know who you are but certainly you are going to a famous blogger if you aren't already ;) Cheers!

Good post. May I post this on my blog? Thanks.

Sometime it can be difficult to find a repairperson that is honest, that won’t ripe you off. Finding someone from out the phone books can be very scary too. Your repair can go very smoothly, when the right steps are taken from the get go.

You can see some who will claim to find wholesalers, but if you know the price of the Louis Vuitton Replica Handbags, go on eBay to compare, you realize you’re just off and will not yield a sufficient profit margin to be useful for resale.

I would say no (unless they're HUGE meals, but even then it's unhealthy to eat like that). You should try to eat 5 small meals a day (in this case, an apple could be considered a meal)

Don't use computer with the charger plugged in unless it needs to be charged. Doing so will kill the battery in short order. Batteries are designed to be discharged and charged. Many say batteries have no memory which I dispute. Read several pages here and you'll find that most of the battery problems are from leaving the charger plugged in.

asentuo que tu punto es util me serviria leer del topico , felicitacion

saludos desde lima peru, les ofrecemos nuestros servicios de posicionamiento web, diseño de paginas web y email marketing.

Thanks for the information. This is something that's becoming more popular and needed every day. I appreciate your post.

Din sida är söt, din grafik är bra, och vad är mer

Awesome work! Keep posting good material.

Would you be all in favour of exchanging links?

Very cool, some interesting arguments! I appreciate you making this article available, the rest of the site is also well done. Have a good.

I am a big admirer of college. I'm sure everybody else should be too.

I've been thinking about going back to college.

What a very nice and insightful post! It’s a fact that muscle growth is highly dependent on what one is eating, what one is lifting, one’s genetics, and what one’s goal is (and you’ve got to have a well-defined goal or else you’d be chasing after your goal forever). In addition to that, one needs to have discipline and dedication to take it to the very end (attainment of the goal that one has set). It shouldn’t be a spur of the moment kind of thing. You need to follow through, just like in anything that you want to succeed in in life. And lastly, it’s all about making everything work together—working out without the proper diet won’t cut it, taking jar after jar of supplements won’t get you bulked up if you don’t pump iron. You need to make everything work together—the right workout program, a proper diet, supplements, and a healthy lifestyle.

Thanks very good for report, I follow your blog

Oh, this is quite interesting. Actulally, I found your blog on google search. I will tell my friend about your blog later.

Between me and my husband we've owned more MP3 players over the years than I can count, including Sansas, iRivers, iPods (classic & touch), the Ibiza Rhapsody, etc. But, the last few years I've settled down to one line of players. Why? Because I was happy to discover how well-designed and fun to use the underappreciated (and widely mocked) Zunes are.

Nice work. You keep working on this blog please.

We are a group of volunteers and starting a new scheme in our community. Your site provided us with valuable info to work on. You have done a formidable job and our whole community will be thankful to you.

Thank you for the good writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! However, how can we communicate?

I have to show thanks to you for bailing me out of this type of instance. As a result of searching throughout the world-wide-web and coming across concepts that were not helpful, I thought my life was over. Living without the answers to the difficulties you have sorted out by means of this guide is a critical case, and ones that would have badly damaged my career if I hadn't encountered your site. The expertise and kindness in taking care of every part was precious. I am not sure what I would've done if I had not encountered such a step like this. I can at this moment relish my future. Thank you so much for the reliable and amazing guide. I won't be reluctant to propose your web blog to any individual who needs to have assistance about this problem.

I am a big admirer of online colleges. I'm sure everybody else would be too.

I think that going to online schools is quickly going to become the best way of getting an education.

This is the appropriate blog for anyone who wants to seek out out about this topic. You notice so much its nearly exhausting to argue with you (not that I truly would want…HaHa). You positively put a brand new spin on a topic thats been written about for years. Great stuff, simply nice!

Your post is very interesting. I've read your blog for few days now and I trully enjoy your blog. Thank you for your great work!

Terrific, this information is exactly what I was searching for.

I enjoy looking through and I conceive this website got some truly utilitarian stuff on it! .

Nice work. You keep working on this blog please.

Hey everyone, I found this pretty cool site value tool at www.webmirable.com it's actually done pretty well compared to the other ones out there. (more appealing atleast) cheers!

About this Archive

Find recent content on the main index or look in the archives to find all content.