1. 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

Discussion in 'Troubleshooting and Problems' started by Luxus, Jan 12, 2014.

  1. Luxus

    Luxus Well-Known Member

    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:

    <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">
            <dd><input type="submit" value="{xen:phrase delete_thread}" class="button primary" /></dd>
        <input type="hidden" name="_xfConfirm" value="1" />
        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    <xen:if is="{$contentTemplate} == 'thread_delete'"></div></xen:if>
    The <div> is nowhere to be seen. Any reasons why?
  2. Brogan

    Brogan XenForo Moderator Staff Member

    If you are already editing the thread_delete template, why do you need the conditional statement to check it is the thread_delete template?
  3. Luxus

    Luxus Well-Known Member

    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.
  4. Chris D

    Chris D XenForo Developer Staff Member

    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.

    .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:

  5. Luxus

    Luxus Well-Known Member

    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.
  6. Syndol

    Syndol Guest

    You could add a 'isOverlay' param in the renderJson() function and then check for that in the template.
  7. Luxus

    Luxus Well-Known Member

    I won't do any file edits. I just don't see why the if conditional method doesn't work. It works elsewhere.
  8. Syndol

    Syndol Guest

    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.

Share This Page