Hello,
I am trying to make a own template and I wish to use an add-on to get own strings and few arrays but somehow I not get it to work correctly could someone maybe see what I do wrong?
I created an addon by following this tutorial: Unmaintained - Global Template Variable
the content looks like this:
In my template I call it like this:
But I always get the error:
My first question is what am I doing wrong how can I actually get database queries into my template into array or in string form?
My second question is in general what is the best way to get your own strings and arays into a template? did I do it correct as the guide showed me or is there a better way?
I am trying to make a own template and I wish to use an add-on to get own strings and few arrays but somehow I not get it to work correctly could someone maybe see what I do wrong?
I created an addon by following this tutorial: Unmaintained - Global Template Variable
the content looks like this:
PHP:
<?php
class Ulyaoth_GlobalTemplateVariable_Listener
{
public static function template_create(&$templateName, array &$ulyaoth, XenForo_Template_Abstract $template)
{
$db = XenForo_Application::get('db');
$q = $db->fetchAll("SELECT`last_thread_title`FROM`xf_forum`");
$ulyaoth['ulytest'] = $q[0];
}
}
In my template I call it like this:
HTML:
<div id="ulyaothMain">
{$ulytest}
</div>
But I always get the error:
Code:
Template Errors: PAGE_CONTAINER
htmlspecialchars() expects parameter 1 to be string, array given in /srv/ulyaoth/library/XenForo/Template/Abstract.php(265) : eval()'d code, line 38:
37:
38: ' . htmlspecialchars($ulytest, ENT_QUOTES, 'UTF-8') . '
39:
My first question is what am I doing wrong how can I actually get database queries into my template into array or in string form?
My second question is in general what is the best way to get your own strings and arays into a template? did I do it correct as the guide showed me or is there a better way?
Last edited: