phpauthenticationopencart

OpenCart text at login page doesnt get changed if I change lines in language files


I run an opencart shop 1.5.6.4 with vqmod installed. I installed xml from opencart in order to force a login before reaching my shop. So it's a closed shop. I customized my login page inside css to hide all menu bars and I "copied" the language selector from the shop into the login page. It's working, but since then the language texts from the connected language files don't get recognized anymore and the login page texts are like "entry_password". But in the language folders/files I connected them correctly. Do you have any hints how to fix this?

Yes, I could write them directly into my login.tpl but then I would only have one language available. I tried to uninstall all vqmod xmls via vqmod manager and got the same result. It looks like the language isn't loaded correctly, but I really don't know why.

This is my login.tpl in catalog/view/theme/default/template/account:

<?php echo $header; ?>
<style>
INLINE CSS
</style>
<div id="banner">
    <center><img src="BANNER URL" alt="header" /></center><br/>
</div>
<?php if ($success) { ?>
<div class="success">Login erfolgreich</div>
<?php } ?>
<?php if ($error_warning) { ?>
<div class="warning">Login fehlgeschlagen</div>
<?php } ?>
<div id="content">
  <div class="login-content">
    <div class="left">
      <h2><?php echo $text_new_customer; ?></h2>
      <div class="content">
        <p><b><?php echo $text_register; ?></b></p>
        <p><?php echo $text_register_account; ?></p>
        <a href="<?php echo $register; ?>" class="button"><?php echo $button_continue; ?></a></div>
    </div>
    <div class="right">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
        <div id="language_selector">Sprache | Language<br>
          <img src="image/flags/de.png" alt="Deutsch" title="Deutsch" onclick="$('input[name=\'language_code\']').attr('value', 'de'); $(this).parent().parent().submit();">
          <img src="image/flags/gb.png" alt="English" title="English" onclick="$('input[name=\'language_code\']').attr('value', 'en'); $(this).parent().parent().submit();">
          <img src="image/flags/nl.png" alt="Nederlands" title="Nederlands" onclick="$('input[name=\'language_code\']').attr('value', 'nl'); $(this).parent().parent().submit();">
          <input type="hidden" name="language_code" value="">
          <input type="hidden" name="redirect" value="http://MYDOMAIN/opencart/index.php?route=account/login">
        </div>
        <div class="content">
          <h2>Login</h2>
          <b>E-Mail:</b><br />
          <input type="text" name="email" value="<?php echo $email; ?>" />
          <br />
          <br />
          <b>Password</b><br />
          <input type="password" name="password" value="<?php echo $password; ?>" />
          <br />
          <a href="<?php echo $forgotten; ?>"><?php echo $text_forgotten; ?></a><br />
          <br />
          <input type="submit" value="<?php echo $button_login; ?>" class="button" />
          <?php if ($redirect) { ?>
          <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
          <?php } ?>
        </div>
      </form>
    </div>
  </div>
  <?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
$('#login input').keydown(function(e) {
    if (e.keyCode == 13) {
        $('#login').submit();
    }
});
//--></script> 
<?php echo $footer; ?>

I want to change the div class content in order to make the h2 and b fields in multilanguage by reading it out from the language-php files:

<div class="content">
<h2><?php echo $text_login; ?></h2>
<b><?php echo $entry_email; ?></b><br />
<input type="text" name="email" value="<?php echo $email; ?>" />
<br />
<br />
<b><?php echo $entry_password; ?></b><br />
<input type="password" name="password" value="<?php echo $password; ?>" />
<br />
<a href="<?php echo $forgotten; ?>"><?php echo $text_forgotten; ?></a><br />
<br />
<input type="submit" value="<?php echo $button_login; ?>" class="button" />
<?php if ($redirect) { ?>
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
<?php } ?>
</div>

this is a language-file login.php example: (located in /catalog/language/english/account/)

<?php
// Heading 
$_['heading_title']                = 'Account Login';

// Text
$_['text_account']                 = 'Account';
$_['text_login']                   = 'Login';
$_['text_new_customer']            = 'New Customer';
$_['text_register']                = 'Register Account';
$_['text_register_account']        = 'By creating an account you will be able to shop faster, be up to date on an order\'s status, and keep track of the orders you have previously made.';
$_['text_returning_customer']      = 'Returning Customer';
$_['text_i_am_returning_customer'] = 'I am a returning customer';
$_['text_forgotten']               = 'Forgotten Password';

// Entry
$_['entry_email']                  = 'E-Mail Address:';
$_['entry_password']               = 'Password:';

// Error
$_['error_login']                  = 'Warning: No match for E-Mail Address     and/or Password.';
$_['error_approved']               = 'Warning: Your account requires approval before you can login.'; 
?>

this is my controller-file login.php example which should connect $entry_email, $entry_password and $text_login into the active language file (english language file see above). It is located in /catalog/controller/account

<?php 
class ControllerAccountLogin extends Controller {
private $error = array();
public function index() {
    $this->load->model('account/customer');

    // Login override for admin users
    if (!empty($this->request->get['token'])) {
        $this->customer->logout();
        $this->cart->clear();

        unset($this->session->data['wishlist']);
        unset($this->session->data['shipping_address_id']);
        unset($this->session->data['shipping_country_id']);
        unset($this->session->data['shipping_zone_id']);
        unset($this->session->data['shipping_postcode']);
        unset($this->session->data['shipping_method']);
        unset($this->session->data['shipping_methods']);
        unset($this->session->data['payment_address_id']);
        unset($this->session->data['payment_country_id']);
        unset($this->session->data['payment_zone_id']);
        unset($this->session->data['payment_method']);
        unset($this->session->data['payment_methods']);
        unset($this->session->data['comment']);
        unset($this->session->data['order_id']);
        unset($this->session->data['coupon']);
        unset($this->session->data['reward']);
        unset($this->session->data['voucher']);
        unset($this->session->data['vouchers']);

        $customer_info = $this->model_account_customer->getCustomerByToken($this->request->get['token']);

        if ($customer_info && $this->customer->login($customer_info['email'], '', true)) {
            // Default Addresses
            $this->load->model('account/address');

            $address_info = $this->model_account_address->getAddress($this->customer->getAddressId());

            if ($address_info) {
                if ($this->config->get('config_tax_customer') == 'shipping') {
                    $this->session->data['shipping_country_id'] = $address_info['country_id'];
                    $this->session->data['shipping_zone_id'] = $address_info['zone_id'];
                    $this->session->data['shipping_postcode'] = $address_info['postcode'];  
                }

                if ($this->config->get('config_tax_customer') == 'payment') {
                    $this->session->data['payment_country_id'] = $address_info['country_id'];
                    $this->session->data['payment_zone_id'] = $address_info['zone_id'];
                }
            } else {
                unset($this->session->data['shipping_country_id']); 
                unset($this->session->data['shipping_zone_id']);    
                unset($this->session->data['shipping_postcode']);
                unset($this->session->data['payment_country_id']);  
                unset($this->session->data['payment_zone_id']); 
            }

            $this->redirect($this->url->link('common/home')); 
        }
    }       

    if ($this->customer->isLogged()) {  
        $this->redirect($this->url->link('common/home'));
    }

    $this->language->load('account/account');

    $this->document->setTitle($this->language->get('heading_title'));

    if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
        unset($this->session->data['guest']);

        // Default Shipping Address
        $this->load->model('account/address');

        $address_info = $this->model_account_address->getAddress($this->customer->getAddressId());

        if ($address_info) {
            if ($this->config->get('config_tax_customer') == 'shipping') {
                $this->session->data['shipping_country_id'] = $address_info['country_id'];
                $this->session->data['shipping_zone_id'] = $address_info['zone_id'];
                $this->session->data['shipping_postcode'] = $address_info['postcode'];  
            }

            if ($this->config->get('config_tax_customer') == 'payment') {
                $this->session->data['payment_country_id'] = $address_info['country_id'];
                $this->session->data['payment_zone_id'] = $address_info['zone_id'];
            }
        } else {
            unset($this->session->data['shipping_country_id']); 
            unset($this->session->data['shipping_zone_id']);    
            unset($this->session->data['shipping_postcode']);
            unset($this->session->data['payment_country_id']);  
            unset($this->session->data['payment_zone_id']); 
        }

        // Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
        if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
            $this->redirect(str_replace('&amp;', '&', $this->request->post['redirect']));
        } else {
            $this->redirect($this->url->link('common/home')); 
        }
    }

    $this->data['breadcrumbs'] = array();

    $this->data['breadcrumbs'][] = array(
        'text'      => $this->language->get('text_home'),
        'href'      => $this->url->link('common/home'),         
        'separator' => false
    );

    $this->data['breadcrumbs'][] = array(
        'text'      => $this->language->get('text_account'),
        'href'      => $this->url->link('account/account', '', 'SSL'),
        'separator' => $this->language->get('text_separator')
    );

    $this->data['breadcrumbs'][] = array(
        'text'      => $this->language->get('text_login'),
        'href'      => $this->url->link('account/login', '', 'SSL'),        
        'separator' => $this->language->get('text_separator')
    );

    $this->data['heading_title'] = $this->language->get('heading_title');

    $this->data['text_new_customer'] = $this->language->get('text_new_customer');
    $this->data['text_register'] = $this->language->get('text_register');
    $this->data['text_register_account'] = $this->language->get('text_register_account');
    $this->data['text_returning_customer'] = $this->language->get('text_returning_customer');
    $this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');
    $this->data['text_forgotten'] = $this->language->get('text_forgotten');

    $this->data['entry_email'] = $this->language->get('entry_email');
    $this->data['entry_password'] = $this->language->get('entry_password');

    $this->data['button_continue'] = $this->language->get('button_continue');
    $this->data['button_login'] = $this->language->get('button_login');

    if (isset($this->error['warning'])) {
        $this->data['error_warning'] = $this->error['warning'];
    } else {
        $this->data['error_warning'] = '';
    }

    $this->data['action'] = $this->url->link('account/login', '', 'SSL');
    $this->data['register'] = $this->url->link('account/register', '', 'SSL');
    $this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');

    // Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
    if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
        $this->data['redirect'] = $this->request->post['redirect'];
    } elseif (isset($this->session->data['redirect'])) {
        $this->data['redirect'] = $this->session->data['redirect'];

        unset($this->session->data['redirect']);            
    } else {
        $this->data['redirect'] = '';
    }

    if (isset($this->session->data['success'])) {
        $this->data['success'] = $this->session->data['success'];

        unset($this->session->data['success']);
    } else {
        $this->data['success'] = '';
    }

    if (isset($this->request->post['email'])) {
        $this->data['email'] = $this->request->post['email'];
    } else {
        $this->data['email'] = '';
    }

    if (isset($this->request->post['password'])) {
        $this->data['password'] = $this->request->post['password'];
    } else {
        $this->data['password'] = '';
    }

    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/login.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/account/login.tpl';
    } else {
        $this->template = 'default/template/account/login.tpl';
    }

    $this->children = array(
        'common/column_left',
        'common/column_right',
        'common/content_top',
        'common/content_bottom',
        'common/footer',
        'common/header' 
    );

    $this->response->setOutput($this->render());
}

protected function validate() {
    if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) {
        $this->error['warning'] = $this->language->get('error_login');
    }

    $customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']);

    if ($customer_info && !$customer_info['approved']) {
        $this->error['warning'] = $this->language->get('error_approved');
    }

    if (!$this->error) {
        return true;
    } else {
        return false;
    }
}
}
?>

What I already tried: - Replace login.tpl with original default login.tpl (in catalog/view/theme/default/template/account) - Remove all vqmod xml's from vqmod manager.

Thanks in advance for your help.


Solution

  • language-file login.php

    $_['text_email1']                 = 'Email Address';
    $_['text_pass1']                 = 'Password';
    

    controller-file login.php

    $this->data['email1'] = $this->language->get('text_email1');
     $this->data['pass1'] = $this->language->get('text_pass1');
    

    Login.tpl

    <div class="content">
              <h2><?php echo $text_login ?></h2>
              <b><?php echo $email1 ?></b><br />
              <input type="text" name="email" value="<?php echo $email; ?>" />
              <br />
              <br />
              <b> <?php echo $pass1 ?> </b><br />
              <input type="password" name="password" value="<?php echo $password; ?>" />
              <br />
              <a href="<?php echo $forgotten; ?>"><?php echo $text_forgotten; ?></a><br />
              <br />
              <input type="submit" value="<?php echo $button_login; ?>" class="button" />
              <?php if ($redirect) { ?>
              <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
              <?php } ?>
            </div>
    

    Add the code in language and controller file,and change div class content with this.