How to use Template Conditional Statements with Template Hook / Listener?

Hello,

I created a very simple Code Event Listener to extend a template:

PHP:
<?php
class Demo_Listener
{
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        switch($hookName)
        {
            case 'ad_above_content':
            {
                $contents .= 'Lorem Ipsum';
                break;
            }
        }
    }
}

Works without a problem. But how can I use Conditional Statements here?

This does not work (show the text to guests only):

PHP:
<?php
class Demo_Listener
{
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        switch($hookName)
        {
            case 'ad_above_content':
            {
                $contents .= '<xen:if is="!{$visitor.user_id}">Lorem Ipsum</xen:if>';
                break;
            }
        }
    }
}

Is there a way to get the content of $visitor object?
 
Use template modifications.

(Admin CP > Appearance > Template Modifications)

Template hooks are deprecated.
 
Ok, good to know. :)

It seems with TMS I can search and replace some stuff. But what shall I search in the template ad_above_content? It has no really content...
Are there any example and/or tutorials about TMS?
 
Back
Top Bottom