Plugin development 2

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
uweD
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Mon May 14, 2007 9:38 pm
Location: Auckland -- New Zealand
Contact:

Plugin development 2

Post by uweD » Tue Aug 28, 2007 3:13 am

Hi,
Well, that was an interesting day... A couple of grey hairs more I have to say. I am still struggling a lot to actually write a plugin in the object orientated fashion which is described here. http://dev.joomla.org/component/option,com_jd-wiki/Itemid,/id,plugins:create_plugin/

Triggering the event works fine (or this is what I believe):

Code: Select all


JPluginHelper::importPlugin('search');
$result = $mainframe->triggerEvent('onSearchSuccesFull',array(&$sResult));






Listening for the event is the core issue for me:

The 'legacy' way works fine:

Code: Select all

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

$mainframe->registerEvent( 'onSearchSuccesFull', 'plgPopulateModule' );
function plgPopulateModule ($param) {
return $param;

}

The object orientated way fails and I simply don't know way at all:

Code: Select all

<?php

defined('_JEXEC') or die();
jimport('joomla.event.plugin');

class plgSearchBar extends JPlugin{

   var $param      =    null;


    function plgSearchBar(& $subject) {
        parent::__construct($subject);
      
        $this->_plugin = JPluginHelper::getPlugin( 'search', 'plgEHiveSearchBar' );
        $this->_params = new JParameter( $this->_plugin->params );
   
    }

    function onSearchSuccesFull ($param) {
      $param = "testPluginEhive";
     
      return $param;
    }
}




It seems to me that Joomla! actually access the file itself but doesn't execute the member function 'onSearchSuccesFull ' which reflects the events name.... What am I missing?

Thanks for your help and sorry for starting a new post but the other one became a bit messy.

Thanks,
Uwe
Last edited by uweD on Wed Aug 29, 2007 5:05 am, edited 1 time in total.
________________________
Uwe Duesing
http://www.uweduesing.com
Skype:uweOnehunga

User avatar
AmyStephen
Joomla! Guru
Joomla! Guru
Posts: 579
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Plugin development 2

Post by AmyStephen » Tue Aug 28, 2007 3:28 am

Uwe -

Is it possible onSearchSuccesFull spelled incorrectly (should be onSearchSuccessful) is a problem?

Just a guess?
Amy :)
~*~ Joomla!'s Queen of the Blues - Jennifer Marriott ~*~
http://OpenSourceCommunity.org/node/1719/

User avatar
uweD
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Mon May 14, 2007 9:38 pm
Location: Auckland -- New Zealand
Contact:

Re: Plugin development 2

Post by uweD » Tue Aug 28, 2007 3:30 am

Hi Amy,

Thanks for pointing that out but I misspelled that event consistently  :)

Thanks,
Uwe
________________________
Uwe Duesing
http://www.uweduesing.com
Skype:uweOnehunga


Post Reply