FizRichard
New member
I'm trying to integrate XenForo 2.3.0 with an external PHP website. I've been following the guide here: https://xenforo.com/community/threads/using-xenforo-code-in-other-applications.194236/
I'm successfully managing to initialize XF and get the logged in user, but what I want to do now is to render the XenForo template with our content pages in it (mostly just for the header and footer).
Following the guide my code is:
The response from renderTemplate is coming back as string(0) "" which can't be right.
Can anyone help or point me in the right direction please?
I'm successfully managing to initialize XF and get the logged in user, but what I want to do now is to render the XenForo template with our content pages in it (mostly just for the header and footer).
Following the guide my code is:
PHP:
// Initialize XF
define('CWD', (($getcwd = getcwd()) ? $getcwd : '.'));
$dir = CWD . '/forum';
require($dir . '/src/XF.php');
\XF::start($dir);
$app = \XF::setupApp('XF\Pub\App');
$app->start();
// Get visitor
$visitor = \XF::visitor();
// Initialize template engine
$templater = \XF::app()->templater();
$globalTemplateData = \XF::app()->getGlobalTemplateData();
$templater->addDefaultParam('xf', $globalTemplateData);
$templater->setStyle(\XF::app()->style(\XF::visitor()->style_id));
$templater->setLanguage(\XF::app()->userLanguage(\XF::visitor()));
$templater = \XF::app()->templater();
// Create the wrapper
$pageParams = $myPageParams;
$pageParams['content'] = '<b>Hello World</b>';
$wrappedResponse = $templater->renderTemplate('public:PAGE_CONTAINER', $pageParams);
// Returns string(0) ""
var_dump($wrappedResponse);
The response from renderTemplate is coming back as string(0) "" which can't be right.
Can anyone help or point me in the right direction please?