Version 5, changed by admin. 10/27/2006. Show version history
Plugin Documentation
Plugins are easy to make. Skim how, then build your first one in about 180 seconds.
Plugins are wiki pages that insert content into the XHTML markup of every page generated by JotSpot. You can use plugins to insert markup, Javascript, or CSS into the pages on your site. Plugins are really easy to create. They are kept in standard Wiki pages that live under /System/Plugins.
Any standard code understood by JotSpot can be used in your plugin. This includes XHTML, JotScript, CSS, and both client-side and server-side.
Note that since your plugin must be edited in XML mode, please pay attention and properly wrap your Javascript code with the correct <script> tag.
Extension points are used to place your plugin's code and UI elements (e.g. links, images, buttons, etc.) within a JotSpot page. Any code wrapped in a extension point will appear in that location within the page's HTML document.
For example, this code inserts two links into the Jot UI -- one at the top of the toolbar, and one in the footer:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:jot="http://www.foopee.com/ns/s3/srvtmpl/"> <jot:extension target="sidebarTop"> <a href="wiki:ProjectHome">Project Home Page</a> </jot:extension> <jot:extension target="footer"> <a href="http://www.google.com">Go to Google</a> </jot:extension> </html>
The table below lists the available extension points. To get an idea where these extension points insert your code, view the map and then check out the plugin code that generated the map.
| Insertion Point | Location |
| head | inside the <head> of the page |
| footer | in the #jot-footer div, right above the #pageFooter div |
| sidebarTop | top of the sidebar/toolbar |
| sidebarBottom | bottom of the sidebar/toolbar |
| bodyStart | just after opening body tag |
| beforeContent | start of the body's main content section |
| afterContent | end of the body's main content section |
| bodyEnd | just before closing body tag |
This plugin adds a big "Click Me" button to the footer that pops an message window when pressed like so:
1) As admin, go to /System/Plugins, enter a plugin name, and click the "Create Plugin" button.
Note for 2.7 wikis:
For 2.7 wikis, the instructions above won't work. Instead please do the following:
2) Copy and paste the code below into the Plugin Contents field on the plugin form. This particular code adds a large button to the footer of every page that pops up a javascript alert window when pressed.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:jot="http://www.foopee.com/ns/s3/srvtmpl/">
<jot:extension target="head">
<script type="text/javascript">
function myFunc() {
alert('${page/name}');
}
</script>
<style type="text/css">
.bigButton {
font-size: 200%;
}
</style>
</jot:extension>
<jot:extension target="footer">
<button class="bigButton" onclick="myFunc();">Click Me</button>
</jot:extension>
</html>
3) The last step is to scroll to the very bottom of the page and check the Make this plugin active by default after installation box. Plugins can be turned on or off by editing the /System/Plugins page and checking the plugin's active box. By checking active by default on this page, we're forcing the plugin to be immediately active.
This plugin targets two extension points: head and footer. It inserts custom javascript and CSS into the HTML <head> of each page, and then inserts a button into the footer, which uses the CSS and javascript to define its look and behavior.
By using the User-level options feature of each plugin, you can extend the users preferences page with options of your choosing. You pick the form elements you need for configuration, and then reference them in your plugin code.
For example, adding this code to our plugin's User-level Options code box adds a checkbox titled "Click me Plugin" in each users' preferences page:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:jot="http://www.foopee.com/ns/s3/srvtmpl/">
<tr>
<td>Click Me Plugin:</td>
<td>
<jot:input name="clickme" selectOptions="On,Off" />
</td>
</tr>
</html>
and then this if statement can then be used in the Plugin Contents code itself to toggle the display of the click me button:
...
<jot:if test="${req/user/userinfo/clickme = 'On'}">
<jot:then>
<jot:extension target="footer">
<button class="bigButton" onclick="myFunc();">Click Me</button>
</jot:extension>
</jot:then>
</jot:if>
...