• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

trying to render template's to none xenforo page

DarkVodka

Formerly Wuebit
#1
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
 

DarkVodka

Formerly Wuebit
#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
 

Luke F

Well-known member
#4
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.
 

DarkVodka

Formerly Wuebit
#5
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
 

DarkVodka

Formerly Wuebit
#6
So far using the code I posted at the start I have this (this is just the user_bar template)

TFR6D99.jpg
It's a start :D

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