MBaas
MBaas

Reputation: 7530

Why is my plugin for Joomla 2.5 not executed?

I am developing a plugin (still a newby to development for 2.5) but somehow I don't even get the beast to do the most basic thing - it seems it is not launched at all. However, PHP's parsor-errors are shown on the Frontend, but when this code is triggered nothing happens - none of diagnostice message are shown on screen or in my logfile...

Where's the problem?

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

    jimport('joomla.plugin.plugin');

    class plgContentSIMPLE_Plugin extends JPlugin
    {
            function plgContentSIMPLE_Plugin( &$subject , $config ) {
                      echo "constructor!";
                parent::__construct( $subject , $config );
            }


            function onPrepareContent ($article , $params, $limitstart)
            {
                  oBDC ("oPC",$article , $params, $limitstart);
                }       

            function onBeforeDisplayContent ($article , $params, $limitstart)
            {
                  oBDC ("oBDC",$article , $params, $limitstart);
             }

           function onAfterDisplayContent ($article , $params, $limitstart)
            {
                  oBDC ("oADC",$article , $params, $limitstart);
             }

             function oBDC($whoscalling,$article , $params, $limitstart)
            {
                      echo "whoscalling = " . $whoscalling;
                      $myFile = "./obdc.log";
                      $fh = fopen($myFile, 'a'); // or die("can't open file");
                      $stringData = "\n whoscalling = " . $whoscalling;
                      fwrite($fh, $stringData);
                      fclose($fh);
             }

}

Upvotes: 0

Views: 136

Answers (2)

MBaas
MBaas

Reputation: 7530

Several issues:

  1. Naming conventions: class plgContentSimple extends JPlugin { function __construct( &$subject , $config ) {
  2. Event is called "onContentAfterDisplay"...

Upvotes: 0

Brent Friar
Brent Friar

Reputation: 10609

How are you installing the plugin? Have you read the Joomla Plugin tutorial? Here is a pretty good tutorial, try getting this to work first -

https://www.inmotionhosting.com/support/edu/joomla-25/create-plugin

Upvotes: 1

Related Questions