Re: [HOW TO] - Welcome Message / Customer Name in Header
Posted: Wed Jul 14, 2010 8:48 am
Fixed, had to do the CSS for that
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Thanks fido-xfido-x wrote:Use this in the header controller (catalog/controller/common/header.php):silanli_53 wrote:How can we show the surname.?
welcome; name lastnameCode: Select all
// Greeting in header if (!$this->customer->isLogged()) { $this->data['text_greeting'] = $this->language->get('text_greeting'); } else { $this->data['text_greeting'] = sprintf($this->language->get('text_logged'), $this->customer->getFirstName() . ' ' . $this->customer->getLastName()); } $this->data['text_create'] = $this->language->get('text_create'); $this->data['create'] = HTTPS_SERVER . 'index.php?route=account/create'; // End Greeting in header
Yes.DannyMacD wrote:Hi Fido and all.
is this 1.4.9 compatible?
many thanks
Hello,fido-x wrote:I've had a few requests for this from people who have visited my dev site. Since this is not mine (it's something that was in version 0.7.7), I'm quite happy to post the necessary information to get it working.
You will need to edit the following files:–
* catalog/controller/common/header.php
* catalog/language/english/common/header.php
* catalog/view/theme/default/template/common/header.tpl
* catalog/view/theme/default/stylesheet/stylesheet.css
catalog/controller/common/header.php
Insert the following:–before:Code: Select all
if (!$this->customer->isLogged()) { $this->data['text_greeting'] = $this->language->get('text_greeting'); } else { $this->load->model('account/customer'); $customer_info = $this->model_account_customer->getCustomer($this->customer->getId()); $this->data['text_greeting'] = sprintf($this->language->get('text_logged'), $customer_info['firstname']); } $this->data['text_create'] = $this->language->get('text_create'); $this->data['text_account'] = $this->language->get('text_account'); $this->data['create'] = $this->url->https('account/create'); $this->data['account'] = $this->url->https('account/account');
(around line 31 in an unmodified setup)Code: Select all
$this->id = 'header';
catalog/language/english/common/header.php
Insert the following:–before the end of the file.Code: Select all
$_['text_greeting'] = 'Welcome, <strong>Guest</strong>'; $_['text_logged'] = 'Welcome back, <strong>%s</strong>'; $_['text_create'] = 'Register'; $_['text_account'] = 'Account';
catalog/view/theme/default/template/common/header.tpl
Insert the following:–beforeCode: Select all
<div class="welcome"> <?php echo $text_greeting; ?> <?php if (!$logged) { ?> [ <a href="<?php echo $login; ?>"><?php echo $text_login; ?></a> ] [ <a href="<?php echo $create; ?>"><?php echo $text_create; ?></a> ] <?php } else { ?> [ <a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a> ] [ <a href="<?php echo $account; ?>"><?php echo $text_account; ?></a> ] <?php } ?> </div>
catalog/view/theme/default/stylesheet/stylesheet.cssCode: Select all
<div class="div4">
Add the following:–At the end of the file.Code: Select all
#header .welcome { clear: both; margin: 10px 0px 10px 0px; text-align: right; }
Enjoy!
im now confused at what code to use for 1.4.9.1 lol anyone throw me a bone please thanksfido-x wrote:Yes.DannyMacD wrote:Hi Fido and all.
is this 1.4.9 compatible?
many thanks
Code: Select all
// Greeting in header
if (!$this->customer->isLogged()) {
$this->data['text_greeting'] = $this->language->get('text_greeting');
} else {
$this->data['text_greeting'] = sprintf($this->language->get('text_logged'), $this->customer->getFirstName());
}
$this->data['text_create'] = $this->language->get('text_create');
$this->data['create'] = HTTPS_SERVER . 'index.php?route=account/create';
// End Greeting in header
Code: Select all
$this->id = 'header';
Code: Select all
$_['text_greeting'] = 'Welcome, <strong>Guest</strong>';
$_['text_logged'] = 'Welcome back, <strong>%s</strong>';
$_['text_create'] = 'Register';
$_['text_account'] = 'Account';
Code: Select all
<div class="welcome">
<?php echo $text_greeting; ?>
<?php if (!$logged) { ?>
[ <a href="<?php echo $login; ?>"><?php echo $text_login; ?></a> ] [ <a href="<?php echo $create; ?>"><?php echo $text_create; ?></a> ]
<?php } else { ?>
[ <a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a> ] [ <a href="<?php echo $account; ?>"><?php echo $text_account; ?></a> ]
<?php } ?>
</div>
Code: Select all
<div class="div4">
Code: Select all
#header .welcome {
float: right;
display: block;
margin-top: 7px;
margin-bottom: 10px;
padding-left: 0px;
}
#header .welcome a {
margin: 0px;
padding: 0px;
background: none;
}