Foo Plugin

Attention: open in a new window.PDFPrintEmail
This is a simple plugin that shows how links are added to Linkr. No content is displayed.

For documentation on building Joomla! plugins, see this page External link.

All this plugin will do is add a link to the Linkr window. Links are added on the server side (see plugin events). Have a look at the PHP plugin file:
<?php
 
// Block direct access to this file
defined('_JEXEC') or die('Restricted');
 
// Plugin libraries
jimport('joomla.plugin.plugin');
 
// Foo plugin example
class plgContentFoo extends JPlugin
{
  function plgContentFoo( &$subject, $config ) {
    parent::__construct( $subject, $config );
  }
 
  /*
   * Linkr links
   */
  function onLinkrGetLinks( $version )
  {
    // Alert the current version of Linkr
    $msg = 'Foo is installed on Linkr '. $version;
 
    // Since this will be added to the "onclick"
    // attribute, use 'single quotes' instead
    // of "double quotes"
    $js = "LinkrHelper.test('". $msg ."')";
 
    // Return link title and javascript statement
    return array(
      'Link Foo' => $js
    );
  }
}
This will add a link Link Foo to the Linkr window. When the link is clicked, a popup message will show the current version of Linkr (see the docs for LinkrHelper.test).

Now, have a look at the XML install file:
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="content">
<name>Content - Foo</name> <version>Tutorial</version> <creationDate>July 2009</creationDate> <description> Foo Plugin - Don't forget to activate the plugin! </description> <files> <filename plugin="foo">foo.php</filename> </files> <params/> </install>
It's important that the group attribute of the install tag be set to content, or your plugin won't be able to communicate with Linkr.

Get the complete plugin and give it a try!

Compatible: Linkr 2.0+, Joomla! 1.5.1+
Attachments:
Download this file (plg.foo.zip) External linkplg.foo.zip External link[Foo Plugin]1 Kb
uBar 0.9 has been released. This is a beta version; there are still some bugs to be worked out. Keep that in mind before using it on a live site.