Post by frishops » Tue Jun 28, 2016 5:45 am

I wish to disable the phone number or change that to email. Any idea where to?

Attachments

phone number.png

phone number.png (277.6 KiB) Viewed 4821 times


Image

Your Local Store.
http://www.frishops.ca
http://www.frishops.cn


New member

Posts

Joined
Tue Sep 15, 2015 5:58 am
Location - Quebec, Canada

Post by straightlight » Tue Jun 28, 2016 6:06 am

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by frishops » Tue Jun 28, 2016 10:14 am

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.

Image

Your Local Store.
http://www.frishops.ca
http://www.frishops.cn


New member

Posts

Joined
Tue Sep 15, 2015 5:58 am
Location - Quebec, Canada

Post by tallica22 » Thu Aug 04, 2016 2:12 pm

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
Last edited by straightlight on Thu Aug 04, 2016 7:36 pm, edited 1 time in total.
Reason: Added code and quote tags.

Newbie

Posts

Joined
Wed Apr 09, 2014 7:45 pm

Post by straightlight » Thu Aug 04, 2016 7:39 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by cyclops12 » Fri Aug 05, 2016 2:33 am

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

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by tallica22 » Fri Aug 05, 2016 5:48 pm

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?

Newbie

Posts

Joined
Wed Apr 09, 2014 7:45 pm

Post by webmedialdh » Fri Aug 05, 2016 6:34 pm

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
Last edited by straightlight on Fri Aug 05, 2016 6:51 pm, edited 1 time in total.
Reason: Added code tags.

Webx IT Solutions
Tel: +91 99154 09292, Skype: webmedialdh, Email: support@webxitsolutions.com
Image


User avatar
New member

Posts

Joined
Fri Apr 22, 2016 5:52 pm
Location - Ludhiana, Punjab

Post by straightlight » Fri Aug 05, 2016 6:53 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by tallica22 » Fri Aug 05, 2016 7:49 pm

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

Newbie

Posts

Joined
Wed Apr 09, 2014 7:45 pm

Post by straightlight » Fri Aug 05, 2016 8:00 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by cyclops12 » Fri Aug 05, 2016 11:36 pm

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!!

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by keyuri33 » Tue Aug 09, 2016 3:56 pm

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.

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by straightlight » Tue Aug 09, 2016 7:14 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by keyuri33 » Wed Aug 10, 2016 1:25 pm

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!

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by straightlight » Wed Aug 10, 2016 6:27 pm

Followed is a topic on how to disable phone number from the header: http://www.opencart.com/index.php?route ... n_id=26132

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 227 guests