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

As Designed {$isAwaitingEmailConfirmation} conditional not working on account_upgrades template

Discussion in 'Resolved Bug Reports' started by lasertits, Feb 1, 2013.

  1. lasertits

    lasertits Active Member

    Not sure if this is a bug, by design, or just my own silly issue (tested on 2 xf installs, one prod one dev, same result) but I can't seem to use the {$isAwaitingEmailConfirmation} template conditional on the account_upgrades template.

    Using the following to test:
    Code:
    <xen:if is="{$isAwaitingEmailConfirmation}">
    testing
    </xen:if>
    When placed on the PAGE_CONTAINER template and viewed on an unconfirmed account, the 'testing' message shows as expected.

    When placed on the account_upgrades template and again viewed on an unconfirmed account, the 'testing' message does not show.

    I also tested it on one of my own templates for an addon of mine and it worked there too. No idea why it isn't functioning on account_upgrades or if it doesn't work on other default XF templates as well.

    If anyone knows how to get it working please let me know. Thanks.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That's a container param. It's not available to the content template without an addon. But you could create a condition to check the {$visitor} array in the template. This is what that var uses:

    Code:
    $params['isAwaitingEmailConfirmation'] = ($visitor['user_id'] && in_array($visitor['user_state'], array('email_confirm', 'email_confirm_edit')));
    
     
    lasertits and Chris D like this.
  3. Chris D

    Chris D XenForo Developer Staff Member

    Yeah unfortunately just because a parameter is available in the PAGE_CONTAINER template, doesn't necessarily mean it will be available to others. And that is basically the problem.

    That conditional is only available to the PAGE_CONTAINER template. It is defined as a parameter in XenForo_Dependencies_Public which sets up all of the parameters for the PAGE_CONTAINER.

    You have a couple of options:

    1) Create an add-on which extends the View which is defined for the account_upgrades controller (XenForo_ViewPublic_Account_Upgrades) and define that parameter. This will make it useable in that template.
    2) Add another conditional in PAGE_CONTAINER something like (syntax may be wrong, going from memory)

    Code:
    <xen:if is="{$contentTemplate} == 'account_upgrades'>[/S]
    [S]<xen:if is="{$isAwaitingEmailConfirmation}">[/S]
    [S]Do something[/S]
    [S]</xen:if>[/S]
    [S]</xen:if>


    This will obviously only work if what you're wanting to do can be injected somewhere within the PAGE_CONTAINER (so before or after the account_upgrades template is rendered).

    Hehe, yeah what Jake the ninja said. Much more elegant actually.

    The actual condition you should be able to use in the template is:

    Code:
    <xen:if is="{$visitor.user_state} == 'email_confirm' || {$visitor.user_state} == 'email_confirm_edit'">
    	Do some stuff
    </xen:if>
     
    lasertits and Jake Bunce like this.
  4. lasertits

    lasertits Active Member

    Thank you both for taking the time to explain and help me out, really appreciate it. And thanks for the conditional Chris, you made solving my issue extremely easy, tested & it works. :)
     

Share This Page