Hello everyone,
I’m trying to figure out how to change the below code. The code is a Joomla plugin which inserts adverts in the main content body of the articles. Is there a way to change this so the plugin renders at the 4th line of content down in my article? Or is this not possible.
<?php
/**
* @version $Id: ads.php 1.0
* @copyright Helen Van-Hotson
* @license GNU/GPL,
* @author - http://www.catchthelight.co.uk/joomla-auto-ads
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onBeforeDisplayContent', 'plgContentads' );
function plgContentads( &$row, &$params, $page=0 )
{
// Hide ads in Modules - doesn't work with newsflash module
if (@$row->content){
return;
}
$view = JRequest::getCmd('view');
$menu =&JSite::getMenu();
$item =&$menu->getActive();
if ($view == 'article'){
$plugin =& JPluginHelper::getPlugin('content', 'ads');
$pluginParams = new JParameter( $plugin->params );
$excluded_Itemids = $pluginParams->get( 'excl_itemids',"" );
if (trim($excluded_Itemids) != '') {
$arr = preg_split("/\\s*,\\s*/", $excluded_Itemids);
if (in_array($item->id, $arr)) {
return ;
}
}
$beforeOrAfter = $pluginParams->get('beforeOrAfter','before');
$alignment = $pluginParams->get('alignment','right');
$padding = $pluginParams->get('padding','4px');
$adcode = $pluginParams->get('adcode'," ");
$text = "<div style='float:".$alignment."; padding:".$padding." ; margin-top:50px;'>";
$text .= "$adcode";
}
$text .= "</div>";
if($beforeOrAfter == 'before'){
$row->text = $text . $row->text;
}else{
$row->text .= $text;
}
return;
}
?>
Could any PHP guru help me out? Thank you very much.