Template Parameters

Quiver

Active member
I am creating an addon which hooks into ad_message_below template.
The addon works. Except for these variables:

Code:
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">

I need these variables to work. Please help.
 
Have you tried:

<xen:if is="{$message.position} == 0 AND !{$message.conversation_id}">
 
I can confirm those conditionals work in the ad_ templates, I use them myself.

Here's mine:
Code:
<xen:hook name="ad_message_below" />
 
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <xen:if is="!{$visitor.user_id}">
        <li class="message">
            <div class="messageUserInfo">
                <div class="messageUserBlock">
                    <div class="avatarHolder" style="height: 102px; width: 102px">
                        <span class="helper"></span>
                        <img src="http://cliptheapex.com/data/avatars/m/0/2.jpg" alt="Avatar" height="96px" width="96px" style="border: 1px solid #C0C0C0; padding: 2px" />
                    </div>
                    <h3 class="userText">
                    <span style="font-weight: bold">Google AdSense</span>
                    <em class="userTitle" itemprop="title">Guest Advertisement</em>
                    </h3>
                    <span class="arrow"><span></span></span>
                </div>
            </div>
            <div class="messageInfo primaryContent">
                <div class="messageContent">
                    <article>
                        <blockquote class="messageText ugc baseHtml">
                            <script type="text/javascript"><!--
                            google_ad_client = "***";
                            /* Message Below */
                            google_ad_slot = "***";
                            google_ad_width = 728;
                            google_ad_height = 90;
                            //-->
                            </script>
                            <script type="text/javascript"
                            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                            </script>
                            <br /><br /><label for="LoginControl"><span style="font-weight: bold; color: #004400"><a href="login/" class="concealed noOutline">Log in or Sign up</a></span></label> to hide all adverts.
                        </blockquote>
                    </article>
                </div>
            </div>
        </li>
    </xen:if>
</xen:if>
 
Have you tried:

<xen:if is="{$message.position} == 0 AND !{$message.conversation_id}">
Doesn't help. The ad is still appearing in conversations and is still appearing after every post.
Basically the external template which hooks into ad_message_below is ignoring parameters.
 
I can confirm those conditionals work in the ad_ templates, I use them myself.

Here's mine:
Code:
<xen:hook name="ad_message_below" />
 
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <xen:if is="!{$visitor.user_id}">
        <li class="message">
            <div class="messageUserInfo">
                <div class="messageUserBlock">
                    <div class="avatarHolder" style="height: 102px; width: 102px">
                        <span class="helper"></span>
                        <img src="http://cliptheapex.com/data/avatars/m/0/2.jpg" alt="Avatar" height="96px" width="96px" style="border: 1px solid #C0C0C0; padding: 2px" />
                    </div>
                    <h3 class="userText">
                    <span style="font-weight: bold">Google AdSense</span>
                    <em class="userTitle" itemprop="title">Guest Advertisement</em>
                    </h3>
                    <span class="arrow"><span></span></span>
                </div>
            </div>
            <div class="messageInfo primaryContent">
                <div class="messageContent">
                    <article>
                        <blockquote class="messageText ugc baseHtml">
                            <script type="text/javascript"><!--
                            google_ad_client = "***";
                            /* Message Below */
                            google_ad_slot = "***";
                            google_ad_width = 728;
                            google_ad_height = 90;
                            //-->
                            </script>
                            <script type="text/javascript"
                            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                            </script>
                            <br /><br /><label for="LoginControl"><span style="font-weight: bold; color: #004400"><a href="login/" class="concealed noOutline">Log in or Sign up</a></span></label> to hide all adverts.
                        </blockquote>
                    </article>
                </div>
            </div>
        </li>
    </xen:if>
</xen:if>
I know it works in ad_message_below.
I have a custom template which hooks into ad_message_below via a template listener.
The template works. The only thing not working is the required parameters. :( Any idea?
 
That hook doesn't pass any params.

You can access the template object to pull params from the content template, but that won't help you to know which post is currently being iterated. I don't know of any other context to help you to identify the first post. Maybe some one else knows.
 
EDIT: Oh I see. Can I see your Listener?
Here is the listener file:
Code:
<?php
class TwistedPromotion_TagCloud_Listener_Listener
{
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if ($hookName == 'ad_message_below')
        {
            $contents .= $template->create('twistedpromotion_tagcloud');
        }
    }
}
 
?>
The external template twistedpromotion_tagcloud is working.
The ad contained in that template shows in ad_message_below.
But the parameters: <xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
Which are ALSO defined in twistedpromotion_tagcloud ... well, they are NOT working. :(
Therefore the ad is appearing after EVERY post and also in Personal Conversations.
Whereas I want it appearing after the first post and not in conversations.
Hence why I used: <xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">

Ideas?
 
Try this:
PHP:
<?php
class TwistedPromotion_TagCloud_Listener_Listener
{
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if ($hookName == 'ad_message_below')
        {
            $contents .= $template->create('twistedpromotion_tagcloud', $template->getParams());
        }
    }
}
 
?>
 
Yeah, thought so. It's basically what Jake said.

You need to use the message_below hook instead, but slightly different to what I said earlier.

This works:

Code:
		if ($hookName == 'message_below')
		{
			$contents .= $template->create('twistedpromotion_tagcloud', $hookParams);
		}
 
Yeah, thought so. It's basically what Jake said.

You need to use the message_below hook instead, but slightly different to what I said earlier.

This works:

Code:
 if ($hookName == 'message_below')
{
$contents .= $template->create('twistedpromotion_tagcloud', $hookParams);
}
Thanks. That's fixed the message appearing after every post issue.
However, it hasn't fixed it from appearing in Personal Conversations.
Any idea how I can get AND !{$message.conversation_id}"> in <xen:if is="{$post.position} == 0 AND !{$message.conversation_id}"> to work?
 
It will be: AND !{$post.conversation_id}

$post and $message aren't used together. It's usually one or other.
 
Top Bottom