Vorweg, ich will nicht Spammen.Aber ich muß ein Problem lösen und weiss nicht weiter.
Hallo,
ich muss eine Komponente weiter entwickeln, sodass Mambots auf den Content einwirken können. Leider bekomme ich kein Ergebniss, bzw immer nur eine "1" heraus
Ziel:
{josprivcontent} im Komponentencontent durch Inhalte im Bot ersetzen.
Was mache ich falsch.![]()
Hier mein Code:
Komponente: privatepage.php
Mambot: mosprivatepage.phpPHP-Code:defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
...
...
$selpage = trim(mosGetParam($_REQUEST, 'selpage', 0));
$pageid = trim(mosGetParam($_REQUEST, 'pageid', 0));
switch($task) {
case 'loadPage':
echo showMyPages($option, $selpage);
break;
default:
echo showMyPages($option);
break;
}
class privCont {
var $id = 0;
var $content = NULL;
function privCont($arg)
{
$this->content = $arg;
}
}
function showMyPages($option, $selpage = "") {
global $database, $my, $_MAMBOTS;
.......
....... $content wird gebaut in privatepage.html.php ( zeige ich jetzt hier nicht an )
.......
$cont = new privCont($content);
$_MAMBOTS->loadBotGroup( 'content' );
$results = $_MAMBOTS->trigger( 'onPrepareContent', array( &$cont, &$params ), true );
return $results;
}
PHP-Code:defined( '_VALID_MOS' ) or die( 'Restricted access' );
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botPrivTemplate' );
/**
*/
function botPrivTemplate( $str=NULL ) {
global $database, $my;
// define the regular expression for the bot
$regex = '/{josprivcontent}/i';
// hier wird entschieden ob die Menüstruktur oder der reine Content angezeigt wird */
...
$content = preg_replace_callback($regex, 'botPrivContent', $str);
...
$content = preg_replace_callback($regex, 'botPrivMenu', $str);
...
}
return $content;
}
/*
* Menu der Private Page wird gebaut
*/
function botPrivMenu()
{
global $database, $my;
$query = "SELECT * FROM #__privatepages_content "
."WHERE userid = ".$my->id
.";";
$database->setQuery( $query );
$data = $database->loadObjectList();
$repl = "<table>\n";
...
... $repl wird gebaut
...
$repl .= "</table>\n";
return $repl;
}
/*
* Inhalte der Menüeintrage werden generiert
*/
function botPrivContent()
{
global $database, $my, $mosConfig_absolute_path;
$query = "SELECT * FROM #__privatepages_content "
."WHERE userid = ".$my->id
." AND id = ".$_REQUEST[privpageid]
.";";
$database->setQuery( $query );
$data = $database->loadObjectList();
$repl = "<table>\n";
...
... $repl wird gebaut
...
$repl .= "</table>\n";
return $repl;
}


LinkBack URL
About LinkBacks

Lesezeichen