JBottero
02-02-2009, 10:10 PM
Here's a basic Content plugin that does not a lot of anything. Just for learning...
I'd like to add additional functions within the class, but get errors every time. How do I add my own functions??? For example, a function that reads a file and returns the content of that file and sets $content to it instead of the root path as I have in this example.
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgContentTest extends JPlugin
{
function onPrepareContent(&$row, &$params, $page)
{
$pattern = "{test}";
$content = JURI::root();
$row->text = preg_replace($pattern, $content, $row->text);
}
}
I'd like to add additional functions within the class, but get errors every time. How do I add my own functions??? For example, a function that reads a file and returns the content of that file and sets $content to it instead of the root path as I have in this example.
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgContentTest extends JPlugin
{
function onPrepareContent(&$row, &$params, $page)
{
$pattern = "{test}";
$content = JURI::root();
$row->text = preg_replace($pattern, $content, $row->text);
}
}