Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

echo product description in meta tag - How to?


RMD27

Recommended Posts

Hi

 

I am using easy populate.

 

I have created extra fields in the product description table.

 

I would like to be able to echo one of these fields in the meta description of each product

 

I have tried this as a test and surprise surprise it doesn't work!

 

 

<meta name="description" content="<?php echo($product_info['products_eta']); ?>">

 

I have also tried

 

<meta name="description" content="<?php echo stripslashes($product_info['products_heading']); ?>">

 

What else do i need to do?

Link to comment
Share on other sites

okay, i found the answer here

 

If you only want the product name to fill the metas like with the header tags auto fill function, you can actually achive that without installing any meta contrib.

 

It requires a very small modification of the file product_info.php

 

Here is how you do it....

 

1.

 

Locate this:

 

Quote

 

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

 

and replace it with this:

 

Quote

 

<title><?php echo $product_info['products_name']; ?></title>

<meta name="description" content="<?php echo $product_info['products_nam"]; ?>">

<meta name="keywords" content="<?php echo $product_info['products_nam"]; ?>">

 

2.

 

locate this code: (about line 72 )

Quote

 

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_info = tep_db_fetch_array($product_info_query);

 

now mark this code section in the file and right click and choose "cut"

 

then locate this pice of code at the top of the file:

 

Quote

 

$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_check = tep_db_fetch_array($product_check_query);

 

Right under this you then just past inn the section you marked previously.

 

 

after you have done so it will look like this:

 

Quote

 

$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_check = tep_db_fetch_array($product_check_query);

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_info = tep_db_fetch_array($product_info_query);

 

 

Thats it.....now all your products will have the products name as tittle, meta description and meta keyword. (Just like if you had been using header tags and the auto fill function)

 

http://www.oscommerce.com/forums/topic/200484-meta-tags-for-your-osc-shop/

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...