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
  • 1207 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
  • 71 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
  • 1207 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
  • 71 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! : )