Post by srain » Sun Feb 10, 2019 10:11 pm

Can I show current page URL in each products' page?

I'm using opencart 3.0.2.0

New member

Posts

Joined
Thu Apr 02, 2015 2:04 am

Post by paulfeakins » Mon Feb 11, 2019 10:23 pm

You mean so that users can copy it?

Are you looking for something like this?
https://www.sharethis.com/

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 srain » Tue Feb 19, 2019 5:16 am

paulfeakins wrote:
Mon Feb 11, 2019 10:23 pm
You mean so that users can copy it?

Are you looking for something like this?
https://www.sharethis.com/
yes, user can copy or save for reference

New member

Posts

Joined
Thu Apr 02, 2015 2:04 am

Post by straightlight » Tue Feb 19, 2019 5:26 am

In catalog/controller/product/product.php file,

find:

Code: Select all

$data['heading_title'] = $product_info['name'];
add below:

Code: Select all

$data['heading_href'] = $this->url->link('product/product', 'language=' . $this->config->get('config_language') . $url . '&product_id=' . (int)$this->request->get['product_id']);
In catalog/language/<your_language_code>/product/product.php file,

add at the bottom:

Code: Select all

$_['text_heading_href'] = 'Current Product';
In catalog/view/theme/<your_theme>/template/product/product.twig file,

add where you want:

Code: Select all

{% if heading_href %}
<a href="{{ heading_href }}">{{ text_heading_href }}</a>
{% endif %}
To show the full URL with your current product line,

from the changes above, replace in your controller file:

Code: Select all

$data['heading_href'] = $this->url->link('product/product', 'language=' . $this->config->get('config_language') . $url . '&product_id=' . (int)$this->request->get['product_id']);
with:

Code: Select all

$data['heading_href'] = HTTPS_SERVER . 'index.php?route=product/product&product_id=' . (int)$product_id;
(Without category filtering)

Then, from your theme file, replace:

Code: Select all

{% if heading_href %}
<a href="{{ heading_href }}">{{ text_heading_href }}</a>
{% endif %}
with:

Code: Select all

{% if heading_href %}
<a href="{{ heading_href }}">{{ heading_href }}</a>
{% endif %}
and you can skip the language file step.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

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

Users browsing this forum: thekrotek and 7 guests