Creating the plugin PHP file

So now we need to write the PHP file that does all the hard work for this plugin and implements the functionality that we are trying to achieve. In your plg_content_clicktocall folder, create the file clicktocall.php with the following code:

<?php defined('_JEXEC') or die; jimport('joomla.plugin.plugin'); class plgContentClicktocall extends JPlugin { function plgContentClicktocall( &$subject, $params ) { parent::__construct( $subject, $params ); } public function onContentPrepare($context, &$row, &$params, $page = 0) { // Do not run this plugin when the content is being indexed if ($context == 'com_finder.indexer') { return true; } if (is_object($row)) { return $this->clickToCall($row->text, $params); } return $this->clickToCall($row, ...

Get Learning Joomla! 3 Extension Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.