Naatan
Well-known member
WARNING: This is for dev's only! Don't use anything posted in this thread unless you know what you're doing!
FYI it's totally possible to use XenForo and Wordpress side-by-side, as in you can run both codebases in the same process, which essentially allows you to show anything you have in Wordpress as part of XenForo and vise-versa.
It's as simple as adding this before your "Autoloader.php" line in XenForo's "index.php" file:
eg. my index.php file looks like this:
You now have full access to all wordpress functionality from within XenForo.
I already experimented a bit by trying to embed XenForo within my Wordpress theme, which works great in theory, but in practice you have a humongous list of css conflicts to resolve. The only way I could see this working properly is if you "design" your wordpress theme in XenForo.
I won't be going doing any more work on this, but I thought I'd share my findings so that other can take it to the next level if they so desire.
This was my experimental code for wrapping XenForo in my Wordpress theme:
xenforo_container.php is basically a Wordpress template that includes the header, footer, sidebar and echo's $content.
All this is of course highly experimental and will likely break lots of stuff, so don't use any of this unless you know what you're doing or like to experiment.
FYI it's totally possible to use XenForo and Wordpress side-by-side, as in you can run both codebases in the same process, which essentially allows you to show anything you have in Wordpress as part of XenForo and vise-versa.
It's as simple as adding this before your "Autoloader.php" line in XenForo's "index.php" file:
PHP:
require('/path/to/wordpress/wp-load.php');
eg. my index.php file looks like this:
PHP:
<?php
$startTime = microtime(true);
$fileDir = dirname(__FILE__);
require('/Users/nathanrijksen/Sites/naatan.com/wp-load.php');
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
$fc = new XenForo_FrontController(new XenForo_Dependencies_Public());
$fc->run();
You now have full access to all wordpress functionality from within XenForo.
I already experimented a bit by trying to embed XenForo within my Wordpress theme, which works great in theory, but in practice you have a humongous list of css conflicts to resolve. The only way I could see this working properly is if you "design" your wordpress theme in XenForo.
I won't be going doing any more work on this, but I thought I'd share my findings so that other can take it to the next level if they so desire.
This was my experimental code for wrapping XenForo in my Wordpress theme:
PHP:
<?php
class WpEmbed_Listen
{
public static function template_post_render($templateName, &$content, array &$containerData, XenForo_Template_Abstract $template)
{
$themePath = '/path/to/wordpress/wp-content/themes/saico/';
if ($templateName != 'PAGE_CONTAINER' OR stripos($_SERVER['REQUEST_URI'],'admin.php'))
{
return;
}
ob_end_clean();
$reporting = error_reporting(E_ALL ^ E_NOTICE);
ob_start();
require_once $themePath . 'xenforo_container.php';
$content = ob_get_contents();
ob_end_clean();
error_reporting($reporting);
ob_start();
}
}
xenforo_container.php is basically a Wordpress template that includes the header, footer, sidebar and echo's $content.
All this is of course highly experimental and will likely break lots of stuff, so don't use any of this unless you know what you're doing or like to experiment.