Robust
Well-known member
I'm following a tutorial and have the following code. I also have two code event listeners, one listening for both of these methods (I think that's what they are haha)
It worked fine when I had the templates in code, but I'm using the template system in XenForo and the tab no longer shows. Not sure why?
Also, is it necessary to pre-load templates? Why should/should you not do it?
Finally, still a little confused on what the & does when it's before a variable name (&$contents)
Thanks!
PHP:
<?php
class newProfileTabs_Listener {
public static function template_create ($templateName, array &$params, XenForo_Template_Abstract $template)
{
switch ($templateName) {
case 'member_view':
$template->preloadTemplate('newProfileTab_ourTab');
$template->preloadTemplate('newProfileTab_ourTab_content');
break;
}
}
public static function template_hook ($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template) {
switch ($hookName)
{
case 'member_view_tabs_heading':
{
$tabTemplate = $template->create('newProfileTabs_ourTab', $template->getParams());
$rendered = $tabTemplate->render();
$contents .= $rendered;
break;
}
case 'member_view_tabs_content':
{
$tabTemplate = $template->create('newProfileTabs_ourTab_content', $template->getParams());
$rendered = $tabTemplate->render();
$contents .= $rendered;
break;
}
}
}
}
It worked fine when I had the templates in code, but I'm using the template system in XenForo and the tab no longer shows. Not sure why?
Also, is it necessary to pre-load templates? Why should/should you not do it?
Finally, still a little confused on what the & does when it's before a variable name (&$contents)
Thanks!