XF 2.2 Using template outside of XF forum

CedNet

Member
New to XF (2) and migrated a large site from vB 4 this weekend.

Intend to use XF outside of the forum. I'm loading the XF framework as per guides I've found here and \XF::start(). It all works and I can get the currently logged in user.

But I can't figure out how to load a specific template, and also parse it and get the actual ready html.

Specifically I want the: helper_js_global, parse from the current XF User / Visitor.

How can I do this?

I've tried this: \XF::app()->templater()->renderTemplate('public:helper_js_global', []) and it turns into an empty string.
 
Last edited:
I made a super hack. I tagged certain areas of a custom view with what I want to use outside of the forum.

Passing the current session via the file_get_conents() function I get all the JS, meta etc that I need outside of the forum. Both as guest and as a logged in user.

My server is pretty speedy so it's "OK" but I wish there was an easier way of doing this than having to boot the whole forum and parse the contents in order to use the forum templates outside of the forum area.
 
I've tried this: \XF::app()->templater()->renderTemplate('public:helper_js_global', []) and it turns into an empty string.
That would work for regular templates, but the public:helper_js_global template only contains macros, meaning it doesn't render anything by default.

You can render a macro in a similar fashion though:
PHP:
$templater = \XF::app()->templater();
$head = $templater->renderMacro('public:helper_js_global', 'head', [
    'app' => 'public',
]);
$body = $templater->renderMacro('public:helper_js_global', 'body', [
    'app' => 'public',
]);

(The third argument is an array of macro arguments.)
 
Thx my man. I will for sure try this out.

Would I be able to do the same on the PAGE_CONTAINER template? Can I also set the nav tree / navigation ID at the same time? It'd then be perfect.I

Can I somehow pass the current session to such template in order to show the logged in version of the template?

Or can I pass the "current visistor" to the XF template from outside the forum?
 
Back
Top Bottom