Page 1 of 1

opencart 3.0.2.0 product and categories custom titles

Posted: Thu Oct 01, 2020 12:50 am
by techplusweb
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!

Re: opencart 3.0.2.0 product and categories custom titles

Posted: Thu Oct 01, 2020 1:00 am
by IP_CAM
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

Re: opencart 3.0.2.0 product and categories custom titles

Posted: Thu Oct 01, 2020 7:57 am
by letxobnav
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

Re: opencart 3.0.2.0 product and categories custom titles

Posted: Fri Oct 02, 2020 2:14 am
by techplusweb
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

Re: opencart 3.0.2.0 product and categories custom titles

Posted: Fri Oct 02, 2020 2:42 am
by letxobnav
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.

Re: opencart 3.0.2.0 product and categories custom titles

Posted: Fri Oct 02, 2020 6:04 am
by techplusweb
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/

Re: opencart 3.0.2.0 product and categories custom titles

Posted: Fri Oct 02, 2020 7:36 am
by letxobnav
Then you should be able to do it within journal settings, check your documentation.