| 1 |
***THIS DOCUMENT IS OUT OF DATE*** |
|---|
| 2 |
================================== |
|---|
| 3 |
|
|---|
| 4 |
How to add a new sidebar plugin |
|---|
| 5 |
=============================== |
|---|
| 6 |
|
|---|
| 7 |
1. Decide on a name. I'll refer to it as <name> below. |
|---|
| 8 |
|
|---|
| 9 |
2. Next, create the plugin's controller in |
|---|
| 10 |
components/plugins/sidebars/<name>_controller.rb. Look at |
|---|
| 11 |
flickr_controller.rb for an example. At a minimum, you need to |
|---|
| 12 |
define two methods: |
|---|
| 13 |
|
|---|
| 14 |
* self.display_name. This is the short name that shows up in |
|---|
| 15 |
title blocks in the sidebar admin UI. |
|---|
| 16 |
|
|---|
| 17 |
* self.description. This is the description that shows up in the |
|---|
| 18 |
UI. |
|---|
| 19 |
|
|---|
| 20 |
If your plugin needs to save configuration options, then you'll |
|---|
| 21 |
need to add a 'configure' method as well, and possible a |
|---|
| 22 |
self.default_config method. Follow the examples. |
|---|
| 23 |
|
|---|
| 24 |
3. Next, create the configuration page. If your sidebar plugin |
|---|
| 25 |
doesn't need any configuration data, then you can skip this step. |
|---|
| 26 |
Otherwise create a file called |
|---|
| 27 |
components/plugins/sidebars/<name>/configure.rhtml and |
|---|
| 28 |
put the form for configuring your plugin into the file. See the |
|---|
| 29 |
existing examples for inspiration. You'll need to include |
|---|
| 30 |
observe_form to get rails to save your data for you. |
|---|
| 31 |
|
|---|
| 32 |
4. Finally, create the plugin's content. This is what is displayed |
|---|
| 33 |
when the sidebar is displayed in the blog. Create a file called |
|---|
| 34 |
components/plugins/sidebars/<name>/content.rhtml and fill it up. |
|---|
| 35 |
Don't forget to include a <h3> header block. Configuration data |
|---|
| 36 |
(if any) is available in @sb_config[<config name>] |
|---|
| 37 |
|
|---|
| 38 |
That's it. New components should be picked up automatically. To |
|---|
| 39 |
enable them, you'll need to use the sidebar tool in the admin page. |
|---|