Vanilla and WordPress integration
2006-11-26 01:28This is mall manual describing steps to integrate Vanilla forum “to the middle” of Wordpress blog: surround forum engine output with Wordpress header, footer, sidebars, etc.
This must be done after you will read and done “official” Wordpress integration manuall for Vanilla. This will allow two apps use the same users base and same authorization.
There are solution existing already on
Vanilla community forum, but my is slightly more elegant way. The benefit ot this solution is slightly better performance — no connection closing and reopening.
Steps:
(1) Go to /library/Framework/ folder. There are file ‘Framework.Class.MySQL.php’ file. Copy it to the same folder, but with name ‘Framework.Class.WordpressDB.php’.
(2) Edit this new file:
(2.1) replace ‘class MySQL extends Database {’ line with:
class WordpressDB extends Database {
(2.2) replace function GetConnection() with this one:
function GetConnection() {
## use DB connection established by WordPress
global $wpdb;
if( $wpdb->dbh ){
$this->Connection = $wpdb->dbh;
} else {
$this->Context->ErrorManager->AddError($this->Context, $this->Name, ‘GetConnection’, ‘$wpdb->dbh does not exist, Wordpress is not initialised:’, $php_errormsg);
}
return $this->Connection;
}
(2.3) replace function MySql(&$Context) with this:
function WordpressDB(&$Context) {
$this->Name = ‘WordpressDB’;
$this->Context = &$Context;
}
(3) in your /conf/settings.php or your /conf/database.php add line:
$Configuration['DATABASE_SERVER'] = ‘WordpressDB’;
(4) go to database and comment out all strings tarting with $Configuration['DATABASE_ -- you will not need them anymore.
If now Vanilla works, create new theme for it and customize it: replace some Vanilla code with WP calls like get_header(), get_footer(), etc.
If you need to change Vanilla templates rendering order, use $Configuration['CONTROL_POSITION_ (...) variables. In my /conf/settings.php file there are two such lines:
$Configuration['CONTROL_POSITION_MENU'] = '598';
$Configuration['CONTROL_POSITION_PANEL'] = ‘599′;
Note that both engines will co-exist in the same space, so conflicts could happens. For example, if you have ‘Role Manager’ Wordpress plugin installed, it will conflict with Vanilla object with the same name.
