Categories > TinyButStrong general >

Can't Understand why the onshow isn't working in this scenario.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Maz
Date: 2006-10-06
Time: 15:16

Can't Understand why the onshow isn't working in this scenario.

I'm having an issue where the following two lines of code aren't being recognised and just don't show anything at all.

[onshow;block=div;when[var.complete]!=1]
[onshow;block=div;when[var.complete]!=0]

The calling code:

<?php
    require_once("../init.php");
   
    //---------------------------------------------
    // INCLUDES AND CLASS REQUIREMENTS
    //---------------------------------------------
    include_once(MAIN_PATH."includes/classes/class.auth.php");
    $auth = new auth($db);
   
    //----------------------------------------------
    // SETUP META CONTENT
    //----------------------------------------------
    $page_data = array(
    'title'     => 'InvisionCube Account Password Reset',
    'desc'         => 'Change your InvisionCube password.',
    'keywords'    => '');

    //----------------------------------------------
    // INITIALISE VARIABLES
    //----------------------------------------------
    $nav_section    =    'public';
    $complete        =     0;
    $has_errors        =     0;
    $warn_message    =    '';
   
    if(isset($kernel->vars_post['btn_reset']) && !empty($kernel->vars_post['btn_reset']))
    {
        $kernel->validate_types($kernel->vars_post, array('username' => 'STR'));
       
        $user_details = $auth->get_mbr_byname($kernel->vars_post['username']);
       
        if(!empty($user_details))
        {
            //----------------------------------------------
            // GENERATE NEW VALIDATION KEY
            //----------------------------------------------
            $validate_key = md5($auth->make_password().uniqid(mt_rand(),TRUE));

            //----------------------------------------------
            // DELETE ANY PREVIOUS VALIDATION ENTRIES
            //----------------------------------------------
            $auth->remove_expired_validations($user_details['id']);
           
            $auth->auth_ip_addr = $kernel->client_info['ip'];
           
            //----------------------------------------------
            // PLACE DETAILS INTO ARRAY FOR CLASS FUNCTION
            //----------------------------------------------
            $data['member_name']    = $user_details['name'];
            $data['member_id']         = $user_details['id'];
            $data['validation_key']    = $validate_key;
            $data['mgroup']            = $user_details['mgroup'];
            $data['email']            = $user_details['email'];
           
            //----------------------------------------------
            // ADD VALIDATIN RECORD TO IPB TABLE
            //----------------------------------------------
            $auth->add_validating($data);
           
            require_once(MAIN_PATH."includes/classes/class.phpmailer.php");
            $mail = new PHPMailer();

            //----------------------------------------------
            // GET EMAIL TEMPLATE
            //----------------------------------------------
            $mail->get_template('pass_reset');
           
            //----------------------------------------------
            // BUILD EMAIL MESSAGE
            //--------------------------------------------
            $mail->build_message( array(
                'SITE_NAME'        => $kernel->settings['site_name'],
                'NAME'             => $data['member_name'],
                'IP_ADDRESS'       => $kernel->client_info['ip'],
                'THE_LINK'         => $kernel->settings['domain'].'auth/pass_reset.php?act=validate&uid='.$data['member_id'].'&vid='.$data['validation_key'].'')
            );
           
            //----------------------------------------------
            // ADD EMAIL DETAILS
            //----------------------------------------------
            $mail->From = $kernel->settings['mailer_address'];
            $mail->AddAddress($data['email']);
            $mail->FromName = $kernel->settings['mailer_from'];
            $mail->Subject = "InvisionCube Password Reset Verification";
            $mail->Body = $mail->message;
           
            //----------------------------------------------
            // SEND EMAIL
            //----------------------------------------------
            $mail->Send();
            $complete = 1;           
        }
        else
        {
            $objForm->err_box[] = $kernel->lang['err_pass_reset_user'];
            $has_errors = 1;
        }
    }
   
    //---------------------------------------------
    // MERGE TEMPLATE AND DISPLAY
    //---------------------------------------------
    $template->LoadTemplate($template_path.'auth/pass_reset.html', false);
    $template->MergeBlock('errors',$objForm->err_box);
    $template->Show();   
   
?>

And the template:

[onload;file=[var.template_path]global/header.html]
            <div id="leadbox">
                <h1>Reset Your InvisionCube Password</h1>
                <p>If you have forgotten your password, you can automatically reset it using
                the instructions below.</p>
                <p>Once you have entered the details, a validation email will be sent to the
                email address associated with your account name.</p>
                <p>Please ensure that you have added [var.kernel.settings.mailer_address]
                to your mail whitelist, to prevent the email being caught by your spam filter.</p>
            </div>
            <div class="hr"><hr /></div>
            <div>[onshow;block=div;when[var.complete]!=1]
                <h2>Enter Current Username</h2>
                <p>Please enter your InvisionCube account name.</p>
                <div id="errorbox">[onshow;block=div;when [var.has_errors]!=0]
                    <h2>[var.kernel.lang.err_rep_head]</h2>
                    <p class="strong">[var.kernel.lang.err_errors_gen]</p>
                    [errors;block=begin][onshow;when [errors;noerr]!='']
                    <p>[errors.val;magnet=p;htmlconv=no]</p>
                    [errors;block=end]
                </div>
                <div class="formbox clearfix">
                    <div class="warning">[onshow;block=div;when[var.warn.message]!='']
                        <p>[var.warn_message;noerr]</p>
                    </div>
                    <div class="helper">
                        <p>Username is a <span class="strong">required field</span> and must be entered.</p>
                    </div>
                    <form name="passform" id="passform" action="[var..script_name]" method="post">
                        <fieldset>
                            <label for="username">Username:</label>
                            <input type="text" class="textbox" name="username" id="username" maxlength="[var.kernel.settings.max_username_len]" style="width: 100%" value="" />
                            <input type="submit" id="btn_reset" name="btn_reset" value="Send" />
                        </fieldset>
                    </form>
                </div>
            </div>
            <div>[onshow;block=div;when[var.complete]!=0]
                <h2>Email Sent</h2>
                <p>An email has been sent to the account holder's email address, giving instructions
                on how to complete the password reset request.</p>
                <p>Your email should be with you in the next few minutes. (Usually instantly.)</p>
            </div>
[onload;file=[var.template_path]global/footer.html]

What am I missing? It must be something blindingly obvious but I'm damned of I can see it...
By: Maz
Date: 2006-10-06
Time: 17:05

Re: Can't Understand why the onshow isn't working in this scenario.

Resolved. I was missing a space after the when in the template.