GManz
GManz

Reputation: 1659

Joomla Plugin not running (is installed)

I have "written" a plugin for Joomla! I say "written" because it is actually someone else's, but it was for Joomla 1.5, and I'm trying to upgrade it to run in Joomla 1.7. However, it's installed and it doesn't want to run. I have tried making it generate an error out of nothing, but it wouldn't give me anything. I'm not even sure if it is Joomla 1.7 code or not, but I'm hoping you could help with that too.

<?php

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

jimport('joomla.plugin.plugin');

class plgContentRegisteredTags extends JPlugin
{
    function plgContentRegisteredTags (&$subject, $params)
    {
        parent::__construct($subject,$params);
    }

    function onPrepareContent ( $context, &$article, &$params, $page=0 )
    {
        global $mainframe;
        //if ( !$published ) return true;

        // define the regular expression for the bot
        $regex1 = "#{reg}(.*?){/reg}#s";
        $regex2 = "#{noreg}(.*?){/noreg}#s";

        // perform the replacement
        $article->text = preg_replace_callback(
            $regex1,
            create_function(
                '$matches',
                'global $my;
                if($my->id) return $matches[1];
                return "";'
            ),
            $article->text
        );

        $article->text = preg_replace_callback(
            $regex2,
            create_function(
                '$matches',
                'global $my;
                if(!$my->id) return $matches[1];
                return "";'
            ),
            $article->text
        );

        return true;
    }
}

Note: it just doesn't want to run at all (no error, no code execution), even though it is enabled and installed.

Any help would be appreciated.

Upvotes: 0

Views: 1453

Answers (1)

Craig
Craig

Reputation: 9330

Plugin-ins in Joomla! are stored in plugins/plugin-type/plugin_name/ relative to the site root. Components are stored in the components/ directory.

eg. the pagebreak content plugin is found at 'plugins/content/pagebreak/' and contains the files:

plugins/content/pagebreak/pagebreak.php
plugins/content/pagebreak/pagebreak.xml
plugins/content/pagebreak/index.html          // not an active file

You can read about creating a content plugin here.

Upvotes: 1

Related Questions