Page 1 of 1

Top header phone number Disable or Change to Email

Posted: Tue Jun 28, 2016 5:45 am
by frishops
I wish to disable the phone number or change that to email. Any idea where to?

Re: Top header phone number Disable or Change to Email

Posted: Tue Jun 28, 2016 6:06 am
by straightlight
The following example will be used for the default template.

In your catalog/view/theme/<your_theme>/template/common/header.tpl file,

find:

Code: Select all

<li><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li>
The $telephone is the variable that defines the contact number.

In your catalog/controller/common/header.php file,

find:

Code: Select all

$data['telephone'] = $this->config->get('config_telephone');
add below:

Code: Select all

$data['email'] = $this->config->get('config_email');
You can now use: $email into your header template file.

Re: Top header phone number Disable or Change to Email

Posted: Tue Jun 28, 2016 10:14 am
by frishops
Very helpful. Thanks a lot.

straightlight wrote:The following example will be used for the default template.

In your catalog/view/theme/<your_theme>/template/common/header.tpl file,

find:

Code: Select all

<li><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li>
The $telephone is the variable that defines the contact number.

In your catalog/controller/common/header.php file,

find:

Code: Select all

$data['telephone'] = $this->config->get('config_telephone');
add below:

Code: Select all

$data['email'] = $this->config->get('config_email');
You can now use: $email into your header template file.

Re: Top header phone number Disable or Change to Email

Posted: Thu Aug 04, 2016 2:12 pm
by tallica22
Hello, I have been trying to do exactly this.
I added

Code: Select all

$data['email'] = $this->config->get('config_email');
to catalog/controller/common/header.php
and changed $telephone to $email in
catalog/view/theme/zerone/template/common/header.tpl
But i get
Notice: Undefined variable: email in /catalog/view/theme/zerone/template/common/header.tpl on line 51
can i please get some help

Re: Top header phone number Disable or Change to Email

Posted: Thu Aug 04, 2016 7:39 pm
by straightlight
tallica22 wrote:Hello, I have been trying to do exactly this.
I added

Code: Select all

$data['email'] = $this->config->get('config_email');
to catalog/controller/common/header.php
and changed $telephone to $email in
catalog/view/theme/zerone/template/common/header.tpl
But i get
Notice: Undefined variable: email in /catalog/view/theme/zerone/template/common/header.tpl on line 51
can i please get some help
No instructions above on my behalf indicates to replace the $email with $telephone. It rather indicates to add the $email variable below the $telephone field.

Re: Top header phone number Disable or Change to Email

Posted: Fri Aug 05, 2016 2:33 am
by cyclops12
In your catalog/controller/common/header.php file,

find:

Code: Select all

$data['telephone'] = $this->config->get('config_telephone');
add below:

Code: Select all

$data['email'] = $this->config->get('config_email');
In catalog/view/theme/YOUR_THEME/template/common/header.tpl find

Code: Select all

        <li><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li>
Add after

Code: Select all

<li><a href="mailto:YOUR_EMAIL_ADDRESS?"><i class="fa fa-envelope"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $email; ?></span></a></li>
Change YOUR_EMAIL_ADDRESS to the email address you wish to use

If you want to remove the telephone number then just comment it out in header.tpl like this

Code: Select all

<!--<li><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li>-->
Hope this helps

Re: Top header phone number Disable or Change to Email

Posted: Fri Aug 05, 2016 5:48 pm
by tallica22
cyclops12 wrote:In your catalog/controller/common/header.php file,

find:

Code: Select all

$data['telephone'] = $this->config->get('config_telephone');
add below:

Code: Select all

$data['email'] = $this->config->get('config_email');
In catalog/view/theme/YOUR_THEME/template/common/header.tpl find

Code: Select all

        <li><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li>
Add after

Code: Select all

<li><a href="mailto:YOUR_EMAIL_ADDRESS?"><i class="fa fa-envelope"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $email; ?></span></a></li>
Change YOUR_EMAIL_ADDRESS to the email address you wish to use

If you want to remove the telephone number then just comment it out in header.tpl like this

Code: Select all

<!--<li><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li>-->
Hope this helps
Hey thanks for the help. i done exactly this and still get
"Notice: Undefined variable: email in /public_html/catalog/view/theme/zerone/template/common/header.tpl on line 52"
Im running version 2.2 if that helps?

Re: Top header phone number Disable or Change to Email

Posted: Fri Aug 05, 2016 6:34 pm
by webmedialdh
Hello,

straightlight is giving you right way to do this, but if it;s still not working then you can use direct method which used by many front-end developers

in Your header.tpl file ( catalog/view/theme/<Your Theme>/template/common/header.tpl )

Search below code

Code: Select all

<li><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li>
and replace with:

Code: Select all

<li><?php global $config; ?><a href="<?php echo $config->get('config_telephone'); ?>"><i class="fa fa-envelope"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $config->get('config_telephone'); ?></span></li>
Make sure try to use straightlight method first as that is default way of work opencart...

Thank You

Re: Top header phone number Disable or Change to Email

Posted: Fri Aug 05, 2016 6:53 pm
by straightlight
The provided codes I specified on the above should work as intended. Although, I do NOT recommend nor suggest to add any globalization functions into the themes as it skips each registered objects being passed through the Object Registry of Opencart.

If there's an email error variable message on your previous post, there is a specific reason for this which is certainly caused by a global function. However, more information would be needed based on the way you did added these codes in order to provide an accurate solution.

Re: Top header phone number Disable or Change to Email

Posted: Fri Aug 05, 2016 7:49 pm
by tallica22
In catalog/controller/common/header.php
Image

In catalog/view/MY_THEME/template/common/header.tpl
Image
It cut off the image but the line is

Code: Select all

<li><a href="mailto:YOUR_EMAIL_ADDRESS?"><i class="fa fa-envelope"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $email; ?></span></a></li>
These are the changes i made?

Thanks

Re: Top header phone number Disable or Change to Email

Posted: Fri Aug 05, 2016 8:00 pm
by straightlight
I would not suggest to use the mailto: method on a website to be contacted but rather a web form with enforced captcha to be filled in order to avoid massive SPAM on your server. A good example would be from the information contact page of your store. Adding your email address to your site header would be really non-recommended as your email address would appear on every pages of your store.

Or, I would simply rename the previous header.php file's instruction line with this:

Code: Select all

$email = str_replace('@', ' at ', $this->config->get('config_email'));
$email = str_replace('.', ' dot ', $email);

$data['email'] = html_entity_decode($email, ENT_QUOTES, 'UTF-8');
to avoid mass SPAM but my first suggestion above would be better, in this case.

As for the $email variable error message, switch back to the default theme from your admin - > extensions - > themes - > Select Default and see if the issue persists.

Note: If your site is already live, set your site under temporary maintenance from your admin - > systems - > settings - > edit store - > server tab - > Maintenance Mode: On before testing the above.

Re: Top header phone number Disable or Change to Email

Posted: Fri Aug 05, 2016 11:36 pm
by cyclops12
straightlight wrote:I would not suggest to use the mailto: method on a website to be contacted but rather a web form with enforced captcha to be filled in order to avoid massive SPAM on your server.
Good point straightlight, i hadnt thought of that.... my bad!!

Re: Top header phone number Disable or Change to Email

Posted: Tue Aug 09, 2016 3:56 pm
by keyuri33
I have use in template (.tpl files). I use global in opencart 2.2 or older version.
For Example:

Code: Select all

<?php global $config; if($config->get('my_style')== 1) { ?>
....html code....
<?php } ?>
but, it does not work in Latest OpenCart 2.3.0.2
Please help me for this issue. this is correct way, please let me know proper way step.

Re: Top header phone number Disable or Change to Email

Posted: Tue Aug 09, 2016 7:14 pm
by straightlight
keyuri33 wrote:I have use in template (.tpl files). I use global in opencart 2.2 or older version.
For Example:

Code: Select all

<?php global $config; if($config->get('my_style')== 1) { ?>
....html code....
<?php } ?>
but, it does not work in Latest OpenCart 2.3.0.2
Please help me for this issue. this is correct way, please let me know proper way step.
Fortunately, it doesn't. Globalization is not a recommended method as it used to surpass the Object Registry of Opencart and I hope this protection on not using globalization further will remain intact.

Re: Top header phone number Disable or Change to Email

Posted: Wed Aug 10, 2016 1:25 pm
by keyuri33
straightlight wrote:Fortunately, it doesn't. Globalization is not a recommended method as it used to surpass the Object Registry of Opencart and I hope this protection on not using globalization further will remain intact.
So, Can you please explain how to it get proper way? with any example code. because, I have not more experienced. I have basic php knowledge. Help would be appreciated. Thank you!

Re: Top header phone number Disable or Change to Email

Posted: Wed Aug 10, 2016 6:27 pm
by straightlight
Followed is a topic on how to disable phone number from the header: http://www.opencart.com/index.php?route ... n_id=26132