RavenLife wrote:
Hi Shinkendo,
nice ideas on usage there :)
is the componentbot a Content Mambot?
if so then this may be the reason for this, you could try change this to a system mambot on load "onAfterStart"
this should load the bot all the time, and may solve the issue, no gurantees though
Thanks for the suggestion. I tried to make it a system mambot (not exactly sure how though) In the PHP and XML for the bot, I changed the references to the 'content' directory to the 'system' directory, and changed the (onContentPrep) to (onAfterStart) then reinstalled the bot. I then got lots of php errors. My inexperience in shining brightly at this point! Still not working. Did I make the correct changes below?
<?php
/**
* @copyright Copyright (C) 2006 Kause Lotski. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
$_MAMBOTS->registerFunction( 'onAfterStart', 'botcomponentbot' );
function botcomponentbot( $published, &$row, &$params, $page=0 ) {
// simple performance check to determine whether bot should process further
if ( strpos( $row->text, 'component' ) === false ) {
return true;
}
// define the regular expression for the bot
$regex = "#{component}(.*?){/component}#s";
// check whether mambot has been unpublished
if ( !$published ) {
$row->text = preg_replace( $regex, '', $row->text );
return true;
}
// perform the replacement
$row->text = preg_replace_callback( $regex, 'botComponentCode_replacer', $row->text );
return true;
}
/**
* Replaces the matched tags an image
* @param array An array of matches (see preg_match_all)
* @return string
*/
function botComponentCode_replacer( &$matches ) {
global $database ;
$query = "SELECT params"
. "\n FROM jos_mambots"
. "\n WHERE element = 'componentbot'"
. "\n AND folder = 'system'"
;
$database->setQuery( $query );
$database->loadObject($mambot);
$botParams = new mosParameters( $mambot->params );
$height = $botParams->def( 'height', '500' );
$width = $botParams->def( 'width', '500' );
$parentopen = $botParams->def( 'parentopen', '0' );
$url = $matches[1];
$url = 'index2.php?' . $url;
$para = 'id="componentbot" '.
'src="'.$url.'" '.
'width="'.$width.'" '.
'height="'.$height.'" '.
'frameborder="0" '.
'allowtransparency="true" '.
'scrolling="no" ';
$url = "<iframe ".$para." >\n".
"<p>Sorry, your browser cannot display frames!</p>\n".
"</iframe>\n";
return $url;
}
?>