Read template in PHP

nrep

Well-known member
I'm working on an addon and I'm able to read variables that I've set in the options page like so:

$title= XenForo_Application::get('options')->addon_title;

However, I can't figure out how to read a template. Is there something simple that I'm missing? I've found out how to add one, but I can't see how to read it :oops:.

Can anyone help this idiot please? ;)
 
In a controller you can return $this->responseView('ViewClassName', 'template_name', array('param1'=>1, 'param2'=>2)
 
In a controller you can return $this->responseView('ViewClassName', 'template_name', array('param1'=>1, 'param2'=>2)

Thanks, I tried that but I get this error : "Using $this when not in object context..."

This is the context:

$newsletterHTML = $this->responseView('Newsletter_Callback_Generate', 'newsletter_email_template');
 
Here's how I've done it for now, just using MySQL:


$db = XenForo_Application::get('db');


$newsletterRAW = $db->fetchOne("
SELECT template
FROM xf_template
WHERE title = 'newsletter_email_template'
LIMIT 1
");
 
Thanks, I tried that but I get this error : "Using $this when not in object context..."

This is the context:

$newsletterHTML = $this->responseView('Newsletter_Callback_Generate', 'newsletter_email_template');

Where are you running this from? Somewhere outside XenForo? Or a template hook?
 
It's inside a callback from an addon I'm using (not sure if that's the correct terminology). The MySQL query works fine though, so that should do the trick :).
 
Back
Top Bottom