• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Conditionals wrapped in conditionals


Active member
I've searched for an answer on this and I can't find the information I need.

I have ads at the top of each thread on my site that only show to guests. I need to make it so that in one specific thread, that ad does not appear for anyone at all.

So I looked at this from the FAQ:

How can I show content in a specific thread?
<xen:if is="{$threadId} == x">
This content will show in thread x
And figured I could do this:

<xen:if is="{$threadId} == 1923">
<p>This content goes in thread 1923</p>
<xen:else />
<div>ad code</div>
That didn't work though. Any ideas why? And then even if I go get it working, can I then wrap all that up in another conditional that says only show that to guests? Sorry if this has been covered elsewhere.


XenForo moderator
Staff member
Which template are you using that in?

Did you make note of the section on container variables in the FAQ?

Similarly for the $threadId variable, you would add this: <xen:container var="$threadId">{$thread.thread_id}</xen:container>.

So you need to add that to the top of the PAGE_CONTAINER template.


Active member
Thanks, Brogan. I'm having a bit of trouble understanding what I need to do.

I had originally tried just putting that code in using the Rotating Ads add-on. That didn't work so I tried adding it to the 'ad_thread_view_above_messages' template which also didn't work.

On the container thing, that's where I really don't follow. I'm reading this from the FAQ:

When working with the PAGE_CONTAINER template, you can pass variables from the view templates (category_view, forum_view, thread_view, etc.) usingxen:container. The same applies to any templates which are included in the PAGE_CONTAINER template; the header or ad_header templates for example.
To use the $forum.node_id variable for example, you would add this to the PAGE_CONTAINER template: <xen:container var="$forumId">{$forum.node_id}</xen:container>.
Similarly for the $threadId variable, you would add this: <xen:container var="$threadId">{$thread.thread_id}</xen:container>.
Do I just put that code I had before inside of this then? Do I replace the "{$thread.thread_id}" with my if/else?

<xen:container var="$threadId">{$thread.thread_id}</xen:container>
And would I not put that into my 'ad_thread_view_above_messages' template rather than the PAGE_CONTAINER?

I'm sorry I'm not following...