Shadab
Well-known member
Here's some sample code I'm using to test (and understand) how template hooks are compiled to php statements. I'm running this code in a separate script, outside of the XenForo/MVC framework.
The compiled php code is:
Which would definitely result in an error, since the 3rd argument for callTemplateHook is expecting an array. Is there any special syntax for passing hardcoded parameters (key-value pairs) to a hook?
PHP:
$text = <<<TEMPLATE
<xen:hook name="template_title.foo" params="foo:bar">
My sample text.
</xen:hook>
TEMPLATE;
$compiler = new XenForo_Template_Compiler($text);
$output = $compiler->compile();
echo $output;
Code:
$__output = '';
$__compilerVar1 = '';
$__compilerVar1 .= '
My sample text.
';
$__output .= $this->callTemplateHook('template_title.foo', $__compilerVar1, 'foo:bar');
unset($__compilerVar1);