BigCommerce - Hosted Ecommerce Software by Interspire

Interspire Forum

Go Back   Interspire Forum > Interspire Shopping Cart Community Forum > Customization and Integration > Code Modification and Development Questions

Thread Tools Display Modes
Old 08-13-2010, 05:12 AM
wurdz + wurdz is offline
Interspire Customer
Join Date: Dec 2004
Location: USA
Posts: 53
Lightbulb Automatic meta descriptions

Has anyone modified the system to pull the meta descriptions from the product description and trimmed the info to 255 characters or something like that?
Reply With Quote
Old 08-14-2010, 01:54 AM
scruffydoo + scruffydoo is offline
Interspire Customer
Join Date: Jan 2009
Location: Brisbane : Australia
Posts: 538

yeah I've got a hack on my site that does this, a guy from the Seobook forum kindly coded it, it was a bit 'knocked up' and not heavily tested but I've been running it for about a year and it seems to work well.

I was having major duplicate content issues and it solves the problem nicely without having to write individual descriptions for each product, nightmare if you've a couple of thousand.

As far as I know it only works on 5.03 but I'll post it if you want, I assumed interspire would've addressed this issue in later releases.
Reply With Quote
Old 08-14-2010, 03:11 AM
wurdz + wurdz is offline
Interspire Customer
Join Date: Dec 2004
Location: USA
Posts: 53

Hi Sean,

That would be excellent. I can modify it if need be to work on another version.

Reply With Quote
Old 08-14-2010, 04:31 AM
scruffydoo + scruffydoo is offline
Interspire Customer
Join Date: Jan 2009
Location: Brisbane : Australia
Posts: 538

OK here go's

The line in red go's in the file : your template/panels/HTMLHead.html

<meta http-equiv="Content-Type" content="text/html; charset=%%GLOBAL_CharacterSet%%" />
	<meta name="keywords" content="%%Page.MetaKeywords%%" />

then go to includes/display/HTMLHead.php and insert this lot in red


	/* Hacky code for meta description below.  By Bromley.
 	* How this works...
 	* - We don't know where the Page.MetaDescription variable is being set
 	* or how to access it from PHP.  Could probably find it but only by
 	* searching the source.
 	* - So instead of accessing it from PHP we insert it into the HTML 
 	* anyway, and comment it out if we're not using it, or wrap the meta
 	* tag around it if we are.
 	* - Can't access $GLOBALS['ProductName'] here, and it doesn't seem to be
 	* set at the time that this method executes.  However, the source for
 	* ProductDetails.php shows how it's got for the ProductDetails.html
 	* panel/template.  Here's the relevant line from that file:
 	* $GLOBALS['ProductName'] =
 	*  isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName());
 	* For this to work, the meta description tag of the HTMLHead.html file
 	* needs to be replaced with:
 	* %%GLOBAL_CustomMetaBefore%%%%Page.MetaDescription%%%%GLOBAL_CustomMetaAfter%%
 	* NB Can't remember if private functions work in PHP4/5/whatever so
 	* making this public like the other one.
	public function fixMetaDescription() {
  	$before = '<meta name="description" content="';
  	$after = '';
  	if (isset($GLOBALS['ISC_CLASS_PRODUCT'])) {
    // We have a product so presumably it's a product page.
    $before .= 'Scrooz Online Fastener and Hardware store - best prices for ' .
    // Now do a little hack to comment out the Page.MetaDescription.
    $before .= '" /><!--';
    $after = '-->';
  } else {
    // It's a category page.  So we just wrap the Page.MetaDescription
    // that's inserted anyway with a meta tag instead of a comment.
    $after = '" />';
  $GLOBALS['CustomMetaBefore'] = $before;
  $GLOBALS['CustomMetaAfter'] = $after;

public function SetPanelSettings()
			// Do we have any live chat service code to show in the header?
			$modules = GetConfig('LiveChatModules');
			if(!empty($modules)) {
				$liveChatClass = GetClass('ISC_LIVECHAT');
				$GLOBALS['LiveChatCode'] = $liveChatClass->GetPageTrackingCode('header');
				$GLOBALS['LiveChatCodeEnabled'] = '';
			} else {
				$GLOBALS['LiveChatCodeEnabled'] = 'display:none';

			$GLOBALS['TrackingCode'] = '';

			// Get the visitor tracking Javascript
			$tracker = GetClass('ISC_VISITOR');
			$GLOBALS['TrackingCode'] .= $tracker->GetTrackingJavascript();

			$GLOBALS['CharacterSet'] = GetConfig('CharacterSet');

			// Are quick searches enabled?
			if(GetConfig('QuickSearch') != 0) {
				$GLOBALS['QuickSearchJS'] = sprintf("<script type=\"text/javascript\" src=\"%s/javascript/quicksearch.js\"></script>", GetConfig('AppPath'));

			// Any additional stylesheets to include?
			$GLOBALS['Stylesheets'] = '';
			if(isset($GLOBALS['AdditionalStylesheets'])) {
				foreach($GLOBALS['AdditionalStylesheets'] as $stylesheet) {
					$GLOBALS['Stylesheets'] .= '<link href="'.$stylesheet.'" type="text/css" rel="stylesheet" />';

			// Are site wide RSS feeds enabled?
			if(!isset($GLOBALS['HeadRSSLinks'])) {
				$GLOBALS['HeadRSSLinks'] = '';

			if(GetConfig('RSSLatestBlogEntries') != 0) {
				$GLOBALS['HeadRSSLinks'] .= GenerateRSSHeaderLink($GLOBALS['ShopPathNormal']."/rss.php?action=newblogs", GetLang('HeadRSSLatestNews'));

			if(GetConfig('RSSNewProducts') != 0) {
				$GLOBALS['HeadRSSLinks'] .= GenerateRSSHeaderLink($GLOBALS['ShopPathNormal']."/rss.php", GetLang('HeadRSSNewProducts'));

			if(GetConfig('RSSPopularProducts') != 0) {
				$GLOBALS['HeadRSSLinks'] .= GenerateRSSHeaderLink($GLOBALS['ShopPathNormal']."/rss.php?action=popularproducts", GetLang('HeadRSSPopularProducts'));

			// Do we need to include the script for design mode?
			if(GetConfig('DesignMode') && isset($_COOKIE['STORESUITE_CP_TOKEN'])) {
				// Include the Admin authorisation class
				if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->IsLoggedIn() && $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Design_Mode)) {
					$GLOBALS['DesignModeStyleSheet'] = sprintf("<link href=\"%s/lib/designmode/designmode.css\" type=\"text/css\" rel=\"stylesheet\" />", $GLOBALS['AppPath']);

					$GLOBALS['DesignModeScriptTag'] = sprintf("<script src=\"%s/lib/designmode/designmode.js\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\">DesignMode.template_page = '%s';</script>", $GLOBALS['AppPath'], $GLOBALS['ISC_CLASS_TEMPLATE']->_tplName.".html");

			// Include the tracking code for each analytics module
			$GLOBALS['TrackingCode'] .= GetTrackingCodeForAllPackages();
			// Bromley change - call the custom function for fixing the meta
			// description.

Bromley is the guy who kindly came up with it and you can see he generously added plenty of commenting to describe what he was doing. Let me know how you get on although I'm no coder and am not on that forum any more so my help would be limited.

Mine is set up to say best prices for (insert product) but you can change this to suit yourself, the hack also only works for product pages, categories and general site pages would need to be changed manually.

Hope it works for you
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump