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

XF 1.3 Help, template conditional not working

imthebest

Well-known member
#1
I have modified template helper_thread_watch_input to set the status of the "Watch this thread..." checkbox always checked only when creating a thread (not when replying to an existing one):

Code:
<xen:if is="{$contentTemplate} == 'thread_create'">
<label for="ctrl_watch_thread"><input type="checkbox" name="watch_thread" value="1" id="ctrl_watch_thread" class="Disabler" checked /> {xen:phrase watch_this_thread_sentence}...</label>
<xen:else />
<label for="ctrl_watch_thread"><input type="checkbox" name="watch_thread" value="1" id="ctrl_watch_thread" class="Disabler" {xen:checked $watchState} /> {xen:phrase watch_this_thread_sentence}...</label>
</xen:if>
Problem it that it's not working. However if I remove the conditional and just replace this:

Code:
<label for="ctrl_watch_thread"><input type="checkbox" name="watch_thread" value="1" id="ctrl_watch_thread" class="Disabler" {xen:checked $watchState} /> {xen:phrase watch_this_thread_sentence}...</label>
With this:

Code:
<label for="ctrl_watch_thread"><input type="checkbox" name="watch_thread" value="1" id="ctrl_watch_thread" class="Disabler" checked /> {xen:phrase watch_this_thread_sentence}...</label>
Then it works but not only on thread_create template but also on thread_reply which I don't want.

What's wrong with the conditional that I'm using? Why it doesn't work?
 

Chris D

XenForo developer
Staff member
#2
If you do this:
Code:
{xen:helper dump, $contentTemplate}
You'll see why.

That template isn't aware of the $contentTemplate conditional.

The solution here is to use the thread record, e.g.
Code:
<xen:if is="{$thread.thread_id}">
An existing thread will have a thread ID, and obviously a thread being created won't.