Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How-To: Use The Product Name As The Page Title Instead Of Categories :: Product Name Rate Topic   * * * * * 1 votes

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 20 July 2018 - 05:57 AM #1

How to use The Product Name As The Page Title

Instead Of Categories :: Product Name

 

 

Please add:
 
#file - if folder structure is missing please create it

app/addons/my_changes/controllers/frontend/products.post.php

#content

<?php

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
	$product = Tygh::$app['view']->getTemplateVars('product');
	if(empty($product['page_title'])){
		//other data can be added to title dynamic also
		$page_title = $product['product'];
		Tygh::$app['view']->assign('page_title', $page_title);
	}
}

* The modification will create the dynamic page title only for products with empty page_tile 

* Tested on CS-Cart 4.8.1
 
PS: "My Changes" add-on needs to be active

 

Please feel free to ask any questions!

 

Keep on smiling,

---
Valentin
part of hungryweb.net



 
  • b4lly
  • Junior Member
  • Members
  • Join Date: 29-Oct 08
  • 81 posts

Posted 25 July 2018 - 01:16 AM #2

How to use The Product Name As The Page Title

Instead Of Categories :: Product Name

 

 

Please add:
 
#file - if folder structure is missing please create it

app/addons/my_changes/controllers/frontend/products.post.php

#content

<?php

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
	$product = Tygh::$app['view']->getTemplateVars('product');
	if(empty($product['page_title'])){
		//other data can be added to title dynamic also
		$page_title = $product['product'];
		Tygh::$app['view']->assign('page_title', $page_title);
	}
}

* The modification will create the dynamic page title only for products with empty page_tile 

* Tested on CS-Cart 4.8.1
 
PS: "My Changes" add-on needs to be active

 

Please feel free to ask any questions!

 

Keep on smiling,

---
Valentin
part of hungryweb.net

Hi Valentin

 

I followed your instructions but received an error, the site would not load any product pages. I'm using version 4.2.3. Any ideas?

 

Thanks



 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 25 July 2018 - 05:04 AM #3

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content
<?php

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
	$product = Registry::get('view')->getTemplateVars('product');
	if(empty($product['page_title'])){
		//other data can be added to title dynamic also
		$page_title = $product['product'];
		Registry::get('view')->assign('page_title', $page_title);
	}
}


 
  • b4lly
  • Junior Member
  • Members
  • Join Date: 29-Oct 08
  • 81 posts

Posted 25 July 2018 - 05:11 AM #4

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content

<?php

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
	$product = Registry::get('view')->getTemplateVars('product');
	if(empty($product['page_title'])){
		//other data can be added to title dynamic also
		$page_title = $product['product'];
		Registry::get('view')->assign('page_title', $page_title);
	}
}

Great, thanks so much Valentin. This works perfectly! : )



 
  • b4lly
  • Junior Member
  • Members
  • Join Date: 29-Oct 08
  • 81 posts

Posted 17 September 2018 - 06:16 AM #5

 

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content

<?php

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
	$product = Registry::get('view')->getTemplateVars('product');
	if(empty($product['page_title'])){
		//other data can be added to title dynamic also
		$page_title = $product['product'];
		Registry::get('view')->assign('page_title', $page_title);
	}
}

Great, thanks so much Valentin. This works perfectly! : )

 

Hi again Valentin

 

I'd also like to automatically capitalize all my product titles eg. masport motor mower = Masport Motor Mower. I believe I would use UCWORDS() for this, but I'm not sure how to correctly incorporate this into the solution you have already provided above. If it's not too much trouble, are you able to show me how this is done?

 

Thanks in advance

: )



 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 17 September 2018 - 08:29 AM #6

 

..

I'd also like to automatically capitalize all my product titles eg. masport motor mower = Masport Motor Mower. I believe I would use UCWORDS() for this, but I'm not sure how to correctly incorporate this into the solution you have already provided above. If it's not too much trouble, are you able to show me how this is done?..

 

Please use:

<?php

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
	$product = Tygh::$app['view']->getTemplateVars('product');
	if(empty($product['page_title'])){
		//other data can be added to title dynamic also
		$page_title = ucwords(strtolower($product['product']));
		Tygh::$app['view']->assign('page_title', $page_title);
	}
}

the only difference is:

$page_title = ucwords(strtolower($product['product']));

Hope this helps!



 
  • b4lly
  • Junior Member
  • Members
  • Join Date: 29-Oct 08
  • 81 posts

Posted 17 September 2018 - 11:43 PM #7

 

 

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content

<?php

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
	$product = Registry::get('view')->getTemplateVars('product');
	if(empty($product['page_title'])){
		//other data can be added to title dynamic also
		$page_title = $product['product'];
		Registry::get('view')->assign('page_title', $page_title);
	}
}

Great, thanks so much Valentin. This works perfectly! : )

 

Hi again Valentin

 

I'd also like to automatically capitalize all my product titles eg. masport motor mower = Masport Motor Mower. I believe I would use UCWORDS() for this, but I'm not sure how to correctly incorporate this into the solution you have already provided above. If it's not too much trouble, are you able to show me how this is done?

 

Thanks in advance

: )

 

Thank you so much Valentin, that's great. Working well. : )



 
  • Antars
  • Advanced Member
  • Members
  • Join Date: 18-Sep 11
  • 51 posts

Posted 01 November 2019 - 08:47 AM #8

that's great, thanks.

Is there a way to add also company name to the title?

like
product name | company name?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22935 posts

Posted 01 November 2019 - 01:35 PM #9

Try 

$page_title = $product['product'] . ' ' .  Registry::get('settings.Company.company_name');

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • AndrewS
  • Member
  • Trial users
  • Join Date: 16-Jun 21
  • 27 posts

Posted 25 June 2021 - 02:27 PM #10

Can you make this work on recent cs-cart 4.12 ?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22935 posts

Posted 28 June 2021 - 05:25 AM #11

At first view, it should work. Please try


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 28 July 2021 - 04:41 AM #12

Can you make this work on recent cs-cart 4.12 ?

 

Yes



 

Posted 02 August 2022 - 04:21 PM #13

We have done it in past we can do it again 

 

Are your looking for safe and secured managed  digital marketing services with access to  seo tools ( Similar to SEMRUSH  on regular basis 

 

 

Connect with us for details discussion just send us Email for proposal and Free Audit report of your website 

 

Along with our services all cs-cart  users get Worth $150 

 

1. Advanced SEO Addon

2. SEO for Tags for creating more related pages with better SEO URL 

 

 

Just Send us Email at Rajesh@gsnindia.com 

 

We will get back with Free Audit Report of your website and  Complete  Digital marketing plan. 

 

We Assure of 100% Money back if no significant changes in your  organic traffic Min Time for engagement is  6 Months.  Our rates are very reasonable. and affordable, 

 

Regards

Rajesh 

SEO and Ecommerce Consultant 


Team Proinvent Systems 

Best of our Service at Fair Rate 

https://www.proinvent.in