Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

KISS Page Titles


gaverp

Recommended Posts

KISS Page Titles

 

I know there are other more significant and robust contributions for the purpose of generating Dynamic Page Titles for their shopping carts.

 

The method defined below only requires the modification of 3 pages and is very "simple" to implement.

 

As of this writing - I'm not certain how Google is going to interpret the titles I'm using - I'm still awaiting their first evaluation of my sitemap.xml file and initial crawl, I will post a result after the crawl and evaluation has completed.

 

There are many other more experienced programmers on this board that could modify the code shown below to be more efficient - hopefully one of them will pitch in - This was a quick fix for my needs and not a long term solution for osCommerce in general.

 

Final Caveat - My shopping cart is heavily modified and 60 hours distant from the initial installation. BACKUP! before you make any changes outlined below.

 

Some background:

The default installation of the osCommerce Shopping cart uses a value set in the Admin panel under the Configuration section titled "Store Name" to set the value used in the page title of ALL pages on your site. Don't worry though - there's really only a couple of pages that need to be modified to create dynamic page titles...

 

Load index.php in your editor. Look for this code around line 40:

<title><?php echo TITLE; ?></title>

 

The "TITLE" variable is where the name of your store is being inserted into your index.php webpage each time the page is called by a customers browser.

 

Using the standard "TITLE" variable with a minor modification - we can have it append the name of the Store Category to the "TITLE" variable so the webpage will display the name of the store followed by the name of the Category selected by the customer (or search engine).

 

When a customer first loads your home page, the page title (set in admin) would read "Blue Shoes". The problem is - that same "title" is used on all of your pages...

 

What you want to see is the page title of each page change to reflect the content that is being displayed.

 

Example...

If your store name is Blue Shoes and you have three categories - Sneakers; High Heels and Sandals, if a customer clicks on the Sneakers category - the page title should read Blue Shoes Sneakers.

 

Now.. if you have 5 different styles of sneakers available on the Sneakers Page - and the user clicks on the one titled "High Top Sneakers" the page title would change to Blue Shoes High Top Sneakers.

 

In some cases though - you might have included the name of your store as a keyword in the name of your product like Blue Shoes High Top Sneakers... so having the original store name -followed by the product name would appear to be "spamming" the search engine with keywords - which I believe may be a bad thing to do.

 

For example...

If you included your store name in your product description (as I did on many of my products) - it would appear in the Page Title as: Blue Shoes Blue Shoes High Top Sneakers. Not to worry though another very simple modification to the code will alleviate this problem too!

 

Here's how to make the changes required to incorporate KISS Page Titles:

 

Time to backup!

I usually save a copy as "xxxx.bak" where "xxxx" is the original file name - if I have to revert back to the original - then I just delete the new file (or rename it to xxxx.BAD and then rename the original back to xxxx.php

 

Back up the following 3 files:

catalog/index.php;

catalog/product_info.php;

catalog/includes/application_top.php

 

Now you're ready to revise the code.

 

Step 1:

On the index.php page you loaded previously replace this line:

<title><?php echo TITLE; ?></title>

 

With this one:

<title><?php echo TITLE . ' ' . $page_name; ?></title>

 

This change will enable your home page to display the categories selected by the user in the page title.

 

Step 2:

Load catalog/includes/application_top.php in your editor and locate the following line of code.

$breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));

 

Insert the following line of code immediately BELOW the line referenced above:

$page_name = $categories['categories_name'];

 

Now, in the same page, locate the following line of code, it should be several lines below the one you just modified:

$breadcrumb->add($model['products_model'],tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' .$cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

 

Insert the following lines of code immediately BELOW the line of code referenced above:

$product_name_query = tep_db_query("select products_name from products_description where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); 
$long_name =tep_db_fetch_array($product_name_query);
$page_name = $long_name['products_name'];

 

Step 3:

Now load catalog/product_info.php into your editor and locate the following line of code:

<title><?php echo TITLE; ?></title>

 

and replace it with this line:

<title><?php echo $page_name; ?></title>

 

Note: if you DO NOT have duplicate keywords in the product name of your products, you can use the following line inplace of the one above.

 

<title><?php echo TITLE . ' ' . $page_name; ?></title>

 

Don't be afraid to try both styles - to see what affect it has on your page titles, and then choose the one that you believe is best suited for your Search Engine Friendly Page Titles.

 

Now - upload your 3 modified pages - depending on which FTP program you are using - you can rename the existing UNMODIFIED files on your server with the .BAK extension, and then upload the modified (NEW) files to the server - that way if something is not right - it's a simple matter to delete the three files you just uploaded on the server and then rename the .BAK files to .php and ... you're back to the original un-modified pages.

 

I hope others will find this modification useful in creating Search Engine Friendly Page Titles...

 

Keeping it simple...

Gaver

diplomacy is the art of saying "nice doggie" - while you look for a rock.

Link to comment
Share on other sites

  • 3 months later...
KISS Page Titles

 

I know there are other more significant and robust contributions for the purpose of generating Dynamic Page Titles for their shopping carts.

 

The method defined below only requires the modification of 3 pages and is very "simple" to implement.

 

As of this writing - I'm not certain how Google is going to interpret the titles I'm using - I'm still awaiting their first evaluation of my sitemap.xml file and initial crawl, I will post a result after the crawl and evaluation has completed.

 

There are many other more experienced programmers on this board that could modify the code shown below to be more efficient - hopefully one of them will pitch in - This was a quick fix for my needs and not a long term solution for osCommerce in general.

 

Final Caveat - My shopping cart is heavily modified and 60 hours distant from the initial installation. BACKUP! before you make any changes outlined below.

 

Some background:

The default installation of the osCommerce Shopping cart uses a value set in the Admin panel under the Configuration section titled "Store Name" to set the value used in the page title of ALL pages on your site. Don't worry though - there's really only a couple of pages that need to be modified to create dynamic page titles...

 

Load index.php in your editor. Look for this code around line 40:

<title><?php echo TITLE; ?></title>

 

The "TITLE" variable is where the name of your store is being inserted into your index.php webpage each time the page is called by a customers browser.

 

Using the standard "TITLE" variable with a minor modification - we can have it append the name of the Store Category to the "TITLE" variable so the webpage will display the name of the store followed by the name of the Category selected by the customer (or search engine).

 

When a customer first loads your home page, the page title (set in admin) would read "Blue Shoes". The problem is - that same "title" is used on all of your pages...

 

What you want to see is the page title of each page change to reflect the content that is being displayed.

 

Example...

If your store name is Blue Shoes and you have three categories - Sneakers; High Heels and Sandals, if a customer clicks on the Sneakers category - the page title should read Blue Shoes Sneakers.

 

Now.. if you have 5 different styles of sneakers available on the Sneakers Page - and the user clicks on the one titled "High Top Sneakers" the page title would change to Blue Shoes High Top Sneakers.

 

In some cases though - you might have included the name of your store as a keyword in the name of your product like Blue Shoes High Top Sneakers... so having the original store name -followed by the product name would appear to be "spamming" the search engine with keywords - which I believe may be a bad thing to do.

 

For example...

If you included your store name in your product description (as I did on many of my products) - it would appear in the Page Title as: Blue Shoes Blue Shoes High Top Sneakers. Not to worry though another very simple modification to the code will alleviate this problem too!

 

Here's how to make the changes required to incorporate KISS Page Titles:

 

Time to backup!

I usually save a copy as "xxxx.bak" where "xxxx" is the original file name - if I have to revert back to the original - then I just delete the new file (or rename it to xxxx.BAD and then rename the original back to xxxx.php

 

Back up the following 3 files:

catalog/index.php;

catalog/product_info.php;

catalog/includes/application_top.php

 

Now you're ready to revise the code.

 

Step 1:

On the index.php page you loaded previously replace this line:

<title><?php echo TITLE; ?></title>

 

With this one:

<title><?php echo TITLE . ' ' . $page_name; ?></title>

 

This change will enable your home page to display the categories selected by the user in the page title.

 

Step 2:

Load catalog/includes/application_top.php in your editor and locate the following line of code.

$breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));

 

Insert the following line of code immediately BELOW the line referenced above:

$page_name = $categories['categories_name'];

 

Now, in the same page, locate the following line of code, it should be several lines below the one you just modified:

$breadcrumb->add($model['products_model'],tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' .$cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

 

Insert the following lines of code immediately BELOW the line of code referenced above:

$product_name_query = tep_db_query("select products_name from products_description where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); 
$long_name =tep_db_fetch_array($product_name_query);
$page_name = $long_name['products_name'];

 

Step 3:

Now load catalog/product_info.php into your editor and locate the following line of code:

<title><?php echo TITLE; ?></title>

 

and replace it with this line:

<title><?php echo $page_name; ?></title>

 

Note: if you DO NOT have duplicate keywords in the product name of your products, you can use the following line inplace of the one above.

 

<title><?php echo TITLE . ' ' . $page_name; ?></title>

 

Don't be afraid to try both styles - to see what affect it has on your page titles, and then choose the one that you believe is best suited for your Search Engine Friendly Page Titles.

 

Now - upload your 3 modified pages - depending on which FTP program you are using - you can rename the existing UNMODIFIED files on your server with the .BAK extension, and then upload the modified (NEW) files to the server - that way if something is not right - it's a simple matter to delete the three files you just uploaded on the server and then rename the .BAK files to .php and ... you're back to the original un-modified pages.

 

I hope others will find this modification useful in creating Search Engine Friendly Page Titles...

 

Keeping it simple...

 

Its really worked a LOT. I say i am very much thankful to you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...