XF 2.2 IF a question thread has a solution...

Old Nick

Well-known member
I try to display content with this conditional statement:
HTML:
<xf:if is="$thread.discussion_type == 'question' && $thread.type_data.solution_post_id != 'null'">
    NO SOLUTION
<xf:else />
    SOLUTION
</xf:if>
But it does not matter if the thread has a solution or not it displays the SOLUTION content, where is my error?
Thanks!
 
Try this instead:

HTML:
<xf:if is="$thread.discussion_type == 'question'">
    <xf:if is="$thread.type_data.solution_post_id == 0">
        No solution
    <xf:else/>
        Solution
    </xf:if>
</xf:if>

Doing it this way will ensure other thread types don't evaluate to the else condition in your original code.

If you only need to check for solution though, just use this:

HTML:
<xf:if is="$thread.type_data.solution_post_id != 0">
        Solution
</xf:if>
 
Doesn't work as expected but i think it's because i user those variables in quick_reply_macros...
That works in the thread_view template btw...

I need to find an other solution to reach my goal.
 
To understand: a variable $variableA responds in the template #templateA. This #templateA template includes a #macrosB template.
Variable $variableA used in #macrosB will not respond correct?
Thanks.
 
Ya but {{ dump(vars()) }} doesn't seem to work for macros template if i use it on quick_reply_macros template nothing is displayed when i browse a thread page.
 
Try this instead:

HTML:
<xf:if is="$thread.discussion_type == 'question'">
    <xf:if is="$thread.type_data.solution_post_id == 0">
        No solution
    <xf:else/>
        Solution
    </xf:if>
</xf:if>

Doing it this way will ensure other thread types don't evaluate to the else condition in your original code.

If you only need to check for solution though, just use this:

HTML:
<xf:if is="$thread.type_data.solution_post_id != 0">
        Solution
</xf:if>
I want to display a widget that contains a list of unsolved questions. Does it work? How?
 
Hello, i'm back on this... How can i set conditional when "Allow question action" is set to Pause or No ?
I dumped variables and find this:
$thread > type_data > allow_question_actions how can i build the conditional with this ?

HTML:
<xf:if is="$thread.type_data.allow_question_actions == 'paused'">
<xf:if is="$thread.type_data.allow_question_actions == 'no'">

??
 
Back
Top Bottom