Post by keiron1992 » Thu Feb 14, 2019 5:09 am

It's been a long time since I last used OpenCart however I seem to have found my way back here and I would like to pick some brains!

I want to display the store phone number within some information pages or the HTML module. Is there anyway I can pull this directly like within template files where I can use {{ telephone }}. If the store phone number changes I'd like to not have to go back through and update each page individually.

Thanks in advance.
Keiron

New member

Posts

Joined
Fri Oct 22, 2010 12:02 am
Location - Birmingham, West Midlands, Uk

Post by boicute.14 » Thu Feb 14, 2019 11:30 am

you can if you know code with str_replace or contact me to get module for resolve your problem

Opencart Developer|Thiết kế website|Thiết kế website tại Đồng Nai


Newbie

Posts

Joined
Sat Oct 22, 2016 2:08 pm

Post by paulfeakins » Thu Feb 14, 2019 7:38 pm

keiron1992 wrote:
Thu Feb 14, 2019 5:09 am
Is there anyway I can pull this directly like within template files where I can use {{ telephone }}. If the store phone number changes I'd like to not have to go back through and update each page individually.
You could add this to your pages:

Code: Select all

{tel}
And then add this to the footer:

Code: Select all

$("body").html($("body").html().replace(/\{tel\}/g,'<a href="tel:123456">123456</a>'));
(Not tested)

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by keiron1992 » Fri Feb 15, 2019 4:58 am

Excellent ideas - thanks guys!

New member

Posts

Joined
Fri Oct 22, 2010 12:02 am
Location - Birmingham, West Midlands, Uk

Post by keiron1992 » Fri Feb 15, 2019 5:21 am

For anyone wanting to do this, I opted for str_replace. Here's the code I used:

Replace in catalog/controller/information/information.php

Code: Select all

$data['description'] = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
with

Code: Select all

$data['description'] = str_replace("{{ telephone }}", $this->config->get('config_telephone'), html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8'));

New member

Posts

Joined
Fri Oct 22, 2010 12:02 am
Location - Birmingham, West Midlands, Uk
Who is online

Users browsing this forum: No registered users and 26 guests