0
votes

I am new to joomla. I am trying to learn some extension development. I already have experience in WordPress themes and plugins. I want to filter a phone number in an article and show it in a appropriate manner. For this I have written test plugin code, but it is not filtering. I have even tried to put an exit statement in the onContentPrepare() hook but it is not working.

/**
 * @package Joomla.Plugin
 * @subpackage Content.ClicktoCall
 * @since 3.0
 * @version 1.0.0
 */
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');

class eqlContentClicktoCall extends JPlugin {

    public function onContentPrepare($context, &$row, &$params, $page = 0) {
// Don't run this plugin when the content is being indexed
        exit();
        if ($context == 'com_finder.indexer') {
            return true;
        }
        if (is_object($row)) {
            return $this->clicktocall($row->text, $params);
        }
        return $this->clicktocall($row);
    }

    protected function clicktocall(&$text) {
        $pattern = '/(\d{4})(\d{3})(\d{4})/';
        $replace = "+92-$1-$2-$3";
        $text=preg_replace($pattern, $replace, $text);
        return true;
    }

}

How can I get this hook to work?

1
its working now i have not added prefix plgContent before plugin. - John Doee
Have you tried removing exit(); ? - Lodder
yup, i put exit() to check if it is working or not, actually it was not hook in because i haven't put plgContent in my plugin classname. i am working on some project : ), i have to do work as it is i will after that i will do R&D on joomla what,why,when,how,where - John Doee

1 Answers

0
votes

You need to change your class name, there's a syntax which if not followed, will cause the plugin to not be triggered. Rename like so:

class plgContentClicktoCall extends JPlugin

In addition, there's rules for how to build out your manifest for installing the plugin.

http://docs.joomla.org/Manifest_files http://svn.joomla.org/project/cms/development/trunk/tests/_data/installer_packages/plg_system_alpha/alpha.xml