Post by techplusweb » Thu Oct 01, 2020 12:50 am

How to setup additional text for title pages.

For example now is just category and product name

I want to show:

For category and subcategories:
Subcategory name | Category name | Website Ttle

for products:
Product name | Subcategory name | Category name | Website Title


Even if it's not possible all thse i am pleased just with some universal keywords and website title.

How to do that?

Thanks you!

New member

Posts

Joined
Wed Dec 17, 2014 6:26 pm

Post by IP_CAM » Thu Oct 01, 2020 1:00 am

Well, for a decent amount of Dollars, someone should be able
to create a Custom Extension for you on this. It's not a matter,
to be solved in a few minutes, better be aware of this ... :D
But you're very seldom around here, as it looks, so, you might
not know ... ::)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by letxobnav » Thu Oct 01, 2020 7:57 am

in catalog/controller/product/product.php
change:

Code: Select all

				if ($category_info) {
					$data['breadcrumbs'][] = array(
						'text' => $category_info['name'],
						'href' => $this->url->link('product/category', 'path=' . $path)
					);
				}
to:

Code: Select all

				if ($category_info) {
					$data['breadcrumbs'][] = array(
						'text' => $category_info['name'],
						'href' => $this->url->link('product/category', 'path=' . $path)
					);
					$main_cat_name = $category_info['name']; // set name for title
				}
change:

Code: Select all

				$data['breadcrumbs'][] = array(
					'text' => $category_info['name'],
					'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
				);
to:

Code: Select all

				$data['breadcrumbs'][] = array(
					'text' => $category_info['name'],
					'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
				);
				$sub_cat_name = $category_info['name']; // set name for title
change:

Code: Select all

			$this->document->setTitle($product_info['meta_title']);
to:

Code: Select all

			$dyn_title = $product_info['name'];
			if (isset($sub_cat_name)) $dyn_title .= '|'.$sub_cat_name;
			if (isset($main_cat_name)) $dyn_title .= '|'.$main_cat_name;
			$dyn_title .= '|'.$this->config->get('config_name');
			$this->document->setTitle($dyn_title);

you basically reuse the category names used for the breadcrumbs to construct the title instead of using the static product meta title.
Use the same principle in catalog/controller/product/category.php

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by techplusweb » Fri Oct 02, 2020 2:14 am

letxobnav wrote:
Thu Oct 01, 2020 7:57 am
in catalog/controller/product/product.php
change:

Code: Select all

				if ($category_info) {
					$data['breadcrumbs'][] = array(
						'text' => $category_info['name'],
						'href' => $this->url->link('product/category', 'path=' . $path)
					);
				}
to:

Code: Select all

				if ($category_info) {
					$data['breadcrumbs'][] = array(
						'text' => $category_info['name'],
						'href' => $this->url->link('product/category', 'path=' . $path)
					);
					$main_cat_name = $category_info['name']; // set name for title
				}
change:

Code: Select all

				$data['breadcrumbs'][] = array(
					'text' => $category_info['name'],
					'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
				);
to:

Code: Select all

				$data['breadcrumbs'][] = array(
					'text' => $category_info['name'],
					'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
				);
				$sub_cat_name = $category_info['name']; // set name for title
change:

Code: Select all

			$this->document->setTitle($product_info['meta_title']);
to:

Code: Select all

			$dyn_title = $product_info['name'];
			if (isset($sub_cat_name)) $dyn_title .= '|'.$sub_cat_name;
			if (isset($main_cat_name)) $dyn_title .= '|'.$main_cat_name;
			$dyn_title .= '|'.$this->config->get('config_name');
			$this->document->setTitle($dyn_title);

you basically reuse the category names used for the breadcrumbs to construct the title instead of using the static product meta title.
Use the same principle in catalog/controller/product/category.php
Thanks for your time helping me.
Unfortunately i followed step-by-step but still is not working.
I also cleaned all caches from opencart admin and from browser and tried with 2 browsers
Does it needs to do modifcations in product.twig files in theme folder?
I copied below all the code from catalog/controller/category.php

New member

Posts

Joined
Wed Dec 17, 2014 6:26 pm

Post by letxobnav » Fri Oct 02, 2020 2:42 am

Does it needs to do modifcations in product.twig files in theme folder?
no, and the changes you made are good so you either are running a non-default template which sets the title itself or you already have a modification of the product.php file.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by techplusweb » Fri Oct 02, 2020 6:04 am

letxobnav wrote:
Fri Oct 02, 2020 2:42 am
Does it needs to do modifcations in product.twig files in theme folder?
no, and the changes you made are good so you either are running a non-default template which sets the title itself or you already have a modification of the product.php file.
Yes I am working with Journal Theme, so it's not the default one, it's a premium.

https://www.journal-theme.com/

New member

Posts

Joined
Wed Dec 17, 2014 6:26 pm

Post by letxobnav » Fri Oct 02, 2020 7:36 am

Then you should be able to do it within journal settings, check your documentation.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 33 guests