trying to render template's to none xenforo page

x4rl

Well-known member
So after read all the awesome post that shadab has done this is what ive come up with so far

PHP:
<?php
$startTime = microtime(true);
$fileDir = '/home/animelon/public_html';

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);

// Not required if you are not using any of the preloaded data
$dependencies = new XenForo_Dependencies_Public();
$dependencies->preLoadData();

XenForo_Session::startPublicSession();

# Rendering a template

$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();

$dependencies->preRenderView();
$viewRenderer = $dependencies->getViewRenderer($response, 'Html', $request);

// Now that you have an html view renderer, you can use it to render any view/template

$viewParams = array(
    'var1' => 'Value 1',
    'var2' => 'Value 2',
);

$content = $viewRenderer->renderView('', $viewParams, '');
echo $content;
This is just in it's own php file for now testing to see if it works and ive done it right

So am guessing the template name will need to go in here

PHP:
$content = $viewRenderer->renderView('', $viewParams, 'HERE');

Am still confused on how I can get the whole header tho, Will I need to add tons of templates to make this work?

Thanks
 
Thanks Dark I was planing on adding all my header on to my booru (shimmie)
this is not the same thing tho right? this is for a custom single page? or am I reading that wrong, Because if this will work for that I love you so much lol <3
 
Thanks Dark I was planing on adding all my header on to my booru (shimmie)
this is not the same thing tho right? this is for a custom single page? or am I reading that wrong, Because if this will work for that I love you so much lol <3

Oh right yeah, that's slightly different. Here's some disjointed code I wrote for Tapatalk that might help you:

PHP:
    $derpView = new XenForo_ViewPublic_Base(
     new XenForo_ViewRenderer_HtmlPublic($this->_dependencies, new Zend_Controller_Response_Http(), $this->_request), 
     new Zend_Controller_Response_Http());

$template = $derpView->createTemplateObject('template_name', array(
    'param' => $param
));
$html = $template->render();

A combination of the addon I posted and/or the code you posted and that should get you rendering templates.
 
Oh right yeah, that's slightly different. Here's some disjointed code I wrote for Tapatalk that might help you:
A combination of the addon I posted and/or the code you posted and that should get you rendering templates.
Hmm if only I knew what you mean lol (y)
Ill keep playing and see what I get, tho am not sure how to combine them :coffee:
Thanks
 
So far using the code I posted at the start I have this (this is just the user_bar template)

TFR6D99.webp
It's a start :D

Tho I am unsure on what to do next >.>
 
Top Bottom