Posted by stefan vaduva on November 12, 2010 at 10:15pm
<?php
chdir('/path/to/forum/dir'); //replace this with your forum path
define( 'IPB_THIS_SCRIPT', 'public' );
require_once( './initdata.php' );
require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );
$reg = ipsRegistry::instance();
$reg->init();
$output = $reg->getClass('output');
$content = render($page['content']); //this adds the Drupal content into the IPB template
$output->addContent($content);
$output->sendOutput();
?>We have 2 problems:
- Login state is not preserved. I guess this is because the Drupal installation is on a different subdomain and the cookie set by IPB is not recognized
- We need a way to make sure that only Drupal is handling the paths while IPB is called from Drupal. For now "?q=user" works but "/user" doesn't work (clean URLs are enabled in Drupal). I have a message in IPB that says "Sorry, we could not locate the page you are requesting to view. Please click here to return back to the forum's home"
Comments
I've solved the problems. The
I've solved the problems. The first one is not a real issue if Drupal is on the same subdomain as IPB and the second one is solved by adding the following line before calling init.data.php
<?phpdefine( 'IPS_DEFAULT_PUBLIC_APP', 'drupal' );
?>
This is code I currently use in html.tpl.php (remember that for now this is just experimental... some things are not really needed but they are left overs from my tests):
<?php
chdir('/path/to/forum/dir);
define( 'IPB_THIS_SCRIPT', 'public' );
define( 'IPS_DEFAULT_PUBLIC_APP', 'drupal' );
require_once( './initdata.php' );
require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );
$reg = ipsRegistry::instance();
$reg->init();
$drupalScripts = '';
$drupalScripts .= '<div id="drupalScripts">'.$scripts.'</div>';
$drupalScripts .= '<script type="text/javascript">';
$drupalScripts .= ' jQuery.noConflict();';
$drupalScripts .= '</script>';
$content = '<div id="drupalContainer">'.$drupalScripts.$styles.$page.$page_bottom.'</div>';
$forum = new forum($reg, $head_title, $content);
class forum
{
function __construct( ipsRegistry $registry, $drupaltitle, $drupalhtml )
{
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php" );
$this->registry->setClass( 'class_forums', new class_forums( $registry ) );
$this->registry->class_forums->forumsInit();
$output = $this->registry->getClass('output');
$output->addContent($drupalhtml);
$output->setTitle($drupaltitle);
$output->sendOutput();
}
}
?>
You may also need to disable
You may also need to disable the overlay module (I haven't checked yet why is not working... but is seems that is related with the fact that IPB also use the #overlay ID and the z-indexes are wrong) and add this in your css file in order to have vertical-tabs displayed correctly:
.clearfix::after {
content: "" !important;
}
drupalContainer .clearfix {
overflow:visible;
}