Hi everybody,
I’m integrating Invision Power Board to my MODx-site by using IPBWI, a very useful and handy library to perform IPB-actions outside its own environment.
I use
require_once('ipb/ipbwi/ipbwi/ipbwi.inc.php'); to integrate the library in
two different snippets. However, when I try to run both snippets in one document, these errors shows up:
Fatal error: Call to a member function isLoggedIn() on a non-object in manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 4
It doesn’t make any sense, because the same member function is used in both snippets, and works fine if I leave out the second snippet call. It doesn’t matter if I use a different and unique function either, it appears with the same error (though with a different function name).
Snippet no. 1 - used to initiate IPBWI and show the appropriate user box:
<?php
require_once('ipb/ipbwi/ipbwi/ipbwi.inc.php');
if($ipbwi->member->isLoggedIn())
{
$user = $ipbwi->member->info();
$modx->setPlaceholder('userName', $user["members_display_name"]);
if($ipbwi->group->isInGroup(array(4,20,21,22)))
{
return $modx->getChunk('userbox2');
}
else
{
return $modx->getChunk('userbox1');
}
}
else
{
return $modx->getChunk('userbox0');
}
?>
Here’s the second snippet (I’ll make the code more MODx-friendly after I make it work!):
<?php
// Initialization
require_once('ipb/ipbwi/ipbwi/ipbwi.inc.php');
if(isset($_POST['new_topic'])){
// create a new topic
if($ipbwi->topic->create(168, $_POST['topic_title'], $_POST['topic_desc'], $_POST['topic_post'])){
$ipbwi->addSystemMessage('Success', '<strong>'.$_POST['topic_title'].'</strong> successful created.');
}
}
if($ipbwi->member->isLoggedIn()){ ?>
<h2>Add a Topic to</h2>
<form action="[(~id~)]" method="post">
<p>Create topic with title <input type="text" name="topic_title" /></p>
<p>and description: <input type="text" name="topic_desc" /></p>
<p>in forum <strong><?php echo $forumName; ?></strong> (<a href="topic_list.php">list forum topics</a>)</p>
<p><textarea name="topic_post" style="width:400px;height:150px;"></textarea></p>
<p><input type="submit" name="new_topic" value="Create new Topic!" /></p>
</form>
<?php }else{ ?>
<p>Please login to add a topic.</p>
<?php }
?>
Thanks, I appreciate all your help