XF 1.5 How To: Set Boolean and Reference Later in Template

justinhowe

Member
Hi all,

I'm using an add-on called TaigaChat Pro which I have heavily modified. The only part I can't seem to get working (and the author hasn't replied to my request in the product forum) is a moderation tool for each li that has content. The technical issue is that I want to move part of the add-on template code inside of a div, but when I do that, it sees a certain boolean as returning true.

Original add-on code:
Code:
<xen:if is="{$message.canModify} OR {$taigachat.canBan} OR {$taigachat.publichtml}">
                                    <div class="Popup" {xen:if $taigachat.publichtml, 'style="display:none"'}>
                                        <a rel="Menu"></a>
                                        <div class="Menu">
                                            <div class="primaryContent menuHeader"><h3>{xen:phrase dark_message_tools}</h3></div>
                                            <ul class="secondaryContent blockLinksList">
                                                <li><a href="{xen:link 'taigachat/edit', $message}" class="OverlayTrigger" data-cacheOverlay="false" id="taigachat_edit_{$message.id}">{xen:phrase edit}</a></li>
                                                <li><a href="{xen:link 'taigachat/delete', $message}" class="taigachat_delete" data-messageid="{$message.id}">{xen:phrase delete}</a></li>
                                                <xen:if is="{$message.user_id} > 0">
                                                    <li id="taigachat_canban_{$message.id}" class="taigachat_canban"><a href="{xen:link 'taigachat/ban', $message}" class="OverlayTrigger" data-cacheOverlay="false">{xen:phrase dark_ban_from_shoutbox}</a></li>
                                                </xen:if>
                                            </ul>
                                        </div>
                                    </div>
                                </xen:if>

The affected part is line 2 where it sets a style of display:none if $taigachat.publichtml is true. If I put this code at the top of the template, outside of any divs, it works fine and publichtml is false. However if I wrap all of this in a div, publichtml returns true. So now what I would like to do is something like:

Pseudo-code:
Code:
<xen:set var="$userCanModerateChat">false</xen:set>
<xen if is="!{$taigachat.publichtml}">
    $userCanModerateChat == true;
</xen:if>

...then later...

<div class="Popup" {xen:if is="!{$userCanModerateChat}" , 'style="display:none"'}>

How would I correctly write this so that $userCanModerateChat is false on template load, then gets set to true if $taigachat.publichtml is false? That's what happens when I have the code outside of the div, but I need it inside the div, so this is the only way I can think of doing it without modifying the code too much.
 
Back
Top Bottom