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

XF 1.2 if conditional doesn't work

Luxus

Well-known member
#1
I will keep this brief. I am trying to add a <div> around the form in the thread_delete template if the content template is thread_delete. This is what I added to the thread_delete template and it doesn't work:

Code:
<xen:if is="{$contentTemplate} == 'thread_delete'"><div></xen:if>
<form action="{xen:link 'threads/delete', $thread}" method="post" class="xenForm formOverlay">

    <xen:include template="helper_deletion_type_unit" />

    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" value="{xen:phrase delete_thread}" class="button primary" /></dd>
    </dl>

    <input type="hidden" name="_xfConfirm" value="1" />
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
</form>
<xen:if is="{$contentTemplate} == 'thread_delete'"></div></xen:if>
The <div> is nowhere to be seen. Any reasons why?
 

Brogan

XenForo moderator
Staff member
#2
If you are already editing the thread_delete template, why do you need the conditional statement to check it is the thread_delete template?
 

Luxus

Well-known member
#3
If you are already editing the thread_delete template, why do you need the conditional statement to check it is the thread_delete template?
Because the thread_delete (among other similar templates) template is used as its own page (if javascript is disabled and you try to delete a thread or if you just open the thread delete page via right click and open) and as an overlay. For design reasons, I need this extra div in the page, but not in the overlay. In fact, if the extra div is added to the overlay, it messes up the html as the title literally jumps out of the overlay box.
 

Chris D

XenForo developer
Staff member
#4
Can you do what you need to do in CSS?

When you navigate to the page, rather than the overlay, the main content container has a class of the template name, e.g.

Code:
.thread_delete .xenForm
Would target the form element in the page, but the .thread_delete class is not there in the overlay version.

So you could do something like this:

upload_2014-1-12_22-47-33.png
 

Luxus

Well-known member
#5
Yeah I used the CSS method before, but it's a pain to manage. It's much easier to use the default CSS and just add an extra div.
 
S

Syndol

Guest
#6
You could add a 'isOverlay' param in the renderJson() function and then check for that in the template.
 
S

Syndol

Guest
#8
I won't do any file edits. I just don't see why the if conditional method doesn't work. It works elsewhere.
Why do you think it is available everywhere else?
It is available in container templates such as PAGE_CONTAINER
See file XenForo_ViewRenderer_HtmlPublic and function renderContainer()

You don't need to edit a file, you could extend a function instead.