mushindo Posted August 31, 2003 Share Posted August 31, 2003 We have oscommerce MS1 installed for one of our clients with the header tags controller, and admin tools for it to allow custom title, keywords and description meta tags on a per product basis. This client currently has over 1500 products though, and wouldnt have the time to write up titles, keywords and descriptions for each individual product. What our idea is, on the product_info.php page, is to run two new queries: 1. First query shall call upon product record, based upon the passed URL product_id. 2. Second query shall update the product_description table within oscommerce, by doing the following: a. taking existing product name, and adding that into the product_meta_title field for same product. b. taking existing product description, and adding that into the product_meta_description field for same product. c. taking existing product name AND model, and adding that into the product_meta_keywords field for same product. Then in theory, the next time the page reloads for this product, the header controller will kick in and show the new automated title, keywords and descirption meta tags directly from the database! I have tried adding the coding manually at the top of the product_info.php page but it keeps tossing errors. I am still learning bit more about PHP, so could anyone help me with this by providing a block of coding for me to use that WOULD work? Thanks in advance! :) Quote Sincerely, Bruce 19 contributions submitted Link to comment Share on other sites More sharing options...
mushindo Posted September 2, 2003 Author Share Posted September 2, 2003 I also realized that it may be possible to insert the product_name, product_model, product_manufacturer all into the keywords field. Also would it wreck anything if i tried to move the main prdocut inquiry near top of page, just above the page title but below these two new queries? Thanks. Quote Sincerely, Bruce 19 contributions submitted Link to comment Share on other sites More sharing options...
TB Posted September 2, 2003 Share Posted September 2, 2003 Bruce, Here's a quick copy of my 'header_tags.php' file. If there's no title listed in the database (ie None entered on products page in admin), then it will show the products name as part of the title. I'd like to be able to get it showing the manufacturer also, though my testing so far hasn't been successful. (ie. Store Name : Manufacturer : Product Name) Cheers, Tony <?php // /catalog/includes/header_tags.php // WebMakers.com Added: Header Tags Generator v2.0 // Add META TAGS and Modify TITLE // // NOTE: Globally replace all fields in products table with current product name just to get things started: // In phpMyAdmin use: UPDATE products_description set PRODUCTS_HEAD_TITLE_TAG = PRODUCTS_NAME // require(DIR_WS_LANGUAGES . $language . '/' . 'header_tags.php'); // echo '<!-- BOF: Generated Meta Tags -->' . "n"; // echo ' <META NAME="Reply-to" CONTENT="' . HEAD_REPLY_TAG_ALL . '">' . "n"; $the_desc=''; $the_key_words=''; $the_title=''; // Define specific settings per page: switch (true) { // DEFAULT.PHP case (strstr($_SERVER['PHP_SELF'],'index.php') or strstr($PHP_SELF,'index.php') ): $the_category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'"); $the_category = tep_db_fetch_array($the_category_query); $the_manufacturers_query= tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"); $the_manufacturers = tep_db_fetch_array($the_manufacturers_query); if (HTDA_DEFAULT_ON=='1') { $the_desc= HEAD_DESC_TAG_DEFAULT . ' ' . HEAD_DESC_TAG_ALL; } else { $the_desc= HEAD_DESC_TAG_DEFAULT; } if (HTKA_DEFAULT_ON=='1') { $the_key_words= HEAD_KEY_TAG_ALL . ' ' . HEAD_KEY_TAG_DEFAULT; } else { $the_key_words= HEAD_KEY_TAG_DEFAULT; } if (HTTA_DEFAULT_ON=='1') { $the_title= HEAD_TITLE_TAG_ALL . ' ' . HEAD_TITLE_TAG_DEFAULT . " " . $the_category['categories_name'] . $the_manufacturers['manufacturers_name']; } else { $the_title= HEAD_TITLE_TAG_DEFAULT; } break; // PRODUCT_INFO.PHP case ( strstr($_SERVER['PHP_SELF'],'product_info.php') or strstr($PHP_SELF,'product_info.php') ): // $the_product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_keywords_tag, pd.products_head_desc_tag, 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_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "'"); $the_product_info_query = tep_db_query("select pd.language_id, p.products_id, pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_keywords_tag, pd.products_head_desc_tag, 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_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'" . " and pd.language_id ='" . (int)$languages_id . "'"); $the_product_info = tep_db_fetch_array($the_product_info_query); $the_manufacturers_query= tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"); $the_manufacturers = tep_db_fetch_array($the_manufacturers_query); if (empty($the_product_info['products_head_desc_tag'])) { $the_desc= HEAD_DESC_TAG_ALL; } else { if ( HTDA_PRODUCT_INFO_ON=='1' ) { $the_desc= $the_product_info['products_head_desc_tag'] . ' ' . HEAD_DESC_TAG_ALL; } else { $the_desc= $the_product_info['products_head_desc_tag']; } } if (empty($the_product_info['products_head_keywords_tag'])) { $the_key_words= HEAD_KEY_TAG_ALL; } else { if ( HTKA_PRODUCT_INFO_ON=='1' ) { $the_key_words= $the_product_info['products_head_keywords_tag'] . ' ' . HEAD_KEY_TAG_ALL; } else { $the_key_words= $the_product_info['products_head_keywords_tag']; } } if (empty($the_product_info['products_head_title_tag'])) { // $the_title= HEAD_TITLE_TAG_ALL; $the_title= HEAD_TITLE_TAG_ALL . ' : ' . clean_html_comments($the_product_info['products_name']); } else { if ( HTTA_PRODUCT_INFO_ON=='1' ) { $the_title= HEAD_TITLE_TAG_ALL . ' : ' . clean_html_comments($the_product_info['products_head_title_tag']); } else { $the_title= clean_html_comments($the_product_info['products_head_title_tag']); } } break; // PRODUCTS_NEW.PHP case ( strstr($_SERVER['PHP_SELF'],'products_new.php') or strstr($PHP_SELF,'products_new.php') ): if ( HEAD_DESC_TAG_WHATS_NEW!='' ) { if ( HTDA_WHATS_NEW_ON=='1' ) { $the_desc= HEAD_DESC_TAG_WHATS_NEW . ' ' . HEAD_DESC_TAG_ALL; } else { $the_desc= HEAD_DESC_TAG_WHATS_NEW; } } else { $the_desc= HEAD_DESC_TAG_ALL; } if ( HEAD_KEY_TAG_WHATS_NEW!='' ) { if ( HTKA_WHATS_NEW_ON=='1' ) { $the_key_words= HEAD_KEY_TAG_WHATS_NEW . ' ' . HEAD_KEY_TAG_ALL; } else { $the_key_words= HEAD_KEY_TAG_WHATS_NEW; } } else { $the_key_words= HEAD_KEY_TAG_ALL; } if ( HEAD_TITLE_TAG_WHATS_NEW!='' ) { if ( HTTA_WHATS_NEW_ON=='1' ) { $the_title= HEAD_TITLE_TAG_ALL . ' ' . HEAD_TITLE_TAG_WHATS_NEW; } else { $the_title= HEAD_TITLE_TAG_WHATS_NEW; } } else { $the_title= HEAD_TITLE_TAG_ALL; } break; // SPECIALS.PHP case ( strstr($_SERVER['PHP_SELF'],'specials.php') or strstr($PHP_SELF,'specials.php') ): if ( HEAD_DESC_TAG_SPECIALS!='' ) { if ( HTDA_SPECIALS_ON=='1' ) { $the_desc= HEAD_DESC_TAG_SPECIALS . ' ' . HEAD_DESC_TAG_ALL; } else { $the_desc= HEAD_DESC_TAG_SPECIALS; } } else { $the_desc= HEAD_DESC_TAG_ALL; } if ( HEAD_KEY_TAG_SPECIALS=='' ) { // Build a list of ALL specials product names to put in keywords $new = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC "); $row = 0; $the_specials=''; while ($new_values = tep_db_fetch_array($new)) { $the_specials .= clean_html_comments($new_values['products_name']) . ', '; } if ( HTKA_SPECIALS_ON=='1' ) { $the_key_words= $the_specials . ' ' . HEAD_KEY_TAG_ALL; } else { $the_key_words= $the_specials; } } else { $the_key_words= HEAD_KEY_TAG_SPECIALS . ' ' . HEAD_KEY_TAG_ALL; } if ( HEAD_TITLE_TAG_SPECIALS!='' ) { if ( HTTA_SPECIALS_ON=='1' ) { $the_title= HEAD_TITLE_TAG_ALL . ' ' . HEAD_TITLE_TAG_SPECIALS; } else { $the_title= HEAD_TITLE_TAG_SPECIALS; } } else { $the_title= HEAD_TITLE_TAG_ALL; } break; // PRODUCTS_REVIEWS_INFO.PHP and PRODUCTS_REVIEWS.PHP case ( strstr($_SERVER['PHP_SELF'],'product_reviews_info.php') or strstr($_SERVER['PHP_SELF'],'product_reviews.php') or strstr($PHP_SELF,'product_reviews_info.php') or strstr($PHP_SELF,'product_reviews.php') ): if ( HEAD_DESC_TAG_PRODUCT_REVIEWS_INFO=='' ) { if ( HTDA_PRODUCT_REVIEWS_INFO_ON=='1' ) { $the_desc= tep_get_header_tag_products_desc((int)$HTTP_GET_VARS['reviews_id']) . ' ' . HEAD_DESC_TAG_ALL; } else { $the_desc= tep_get_header_tag_products_desc((int)$HTTP_GET_VARS['reviews_id']); } } else { $the_desc= HEAD_DESC_TAG_PRODUCT_REVIEWS_INFO; } if ( HEAD_KEY_TAG_PRODUCT_REVIEWS_INFO=='' ) { if ( HTKA_PRODUCT_REVIEWS_INFO_ON=='1' ) { $the_key_words= tep_get_header_tag_products_keywords((int)$HTTP_GET_VARS['reviews_id']) . ' ' . HEAD_KEY_TAG_ALL; } else { $the_key_words= tep_get_header_tag_products_keywords((int)$HTTP_GET_VARS['reviews_id']); } } else { $the_key_words= HEAD_KEY_TAG_PRODUCT_REVIEWS_INFO; } if ( HEAD_TITLE_TAG_PRODUCT_REVIEWS_INFO=='' ) { if ( HTTA_PRODUCT_REVIEWS_INFO_ON=='1' ) { $the_title= HEAD_TITLE_TAG_ALL . ' ' . tep_get_header_tag_products_title((int)$HTTP_GET_VARS['reviews_id']); } else { $the_title= tep_get_header_tag_products_title((int)$HTTP_GET_VARS['reviews_id']); } } else { $the_title= HEAD_TITLE_TAG_PRODUCT_REVIEWS_INFO; } break; // ALL OTHER PAGES NOT DEFINED ABOVE default: $the_desc= HEAD_DESC_TAG_ALL; $the_key_words= HEAD_KEY_TAG_ALL; $the_title= HEAD_TITLE_TAG_ALL; break; } echo ' <META NAME="Description" Content="' . $the_desc . '">' . "n"; echo ' <META NAME="Keywords" CONTENT="' . $the_key_words . '">' . "n"; if (isset($HTTP_GET_VARS['products_id'])) { echo ' <title>' . $the_title . '</title>' . "n"; } else { echo "<title>" . TITLE . " : " . $breadcrumb->currentTitle() . "</title>"; } // echo '<!-- EOF: Generated Meta Tags -->' . "n"; ?> Quote "The price of success is perseverance. The price of failure comes much cheaper." Link to comment Share on other sites More sharing options...
mushindo Posted September 2, 2003 Author Share Posted September 2, 2003 Thanks for the help. This does help me somewhat, but main thing I am trying to do within the product_info.php page is: 1. do new product table inquiry2. do a corresponding product_description table inquiry 3. if the following new fields (from header controller contribution) are null: products_head_title_tag products_head_desc_tag products_head_keywords_tag Then it should update them with existing product_description information in the database. Example: products_head_title_tag would = products_name value. Pretty much Im trying to use a query to update the database with existing fields into the new fields for the meta tags. Another reason why I am choosing to do it this way is since my client hs requested that his website be spidered by search engines so someone could put in a modle number or a product name and see his site come up. Long story....anyways..lol. I know it should jsut be two quick queries, but everytime i try it my coding bombs out. My coding was so bad on this page truthfully I deleted it completely otherwise I would post it here. Any help is greatly appreciated. Quote Sincerely, Bruce 19 contributions submitted Link to comment Share on other sites More sharing options...
coffman Posted September 4, 2003 Share Posted September 4, 2003 Tony, To get the manufactures name you have to do a second query as the product_info page does not include the $HTTP_GET_VARS['manufacturers_id'] value. I wanted to do the same thing and have added the following: $the_manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = '" . (int)$languages_id . "'), " . TABLE_PRODUCTS . " p where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.manufacturers_id = m.manufacturers_id"); $the_manufacturers = tep_db_fetch_array($manufacturer_query); to the product_info.php section of the header_tags.php file. It seems to work fine for me.. Good Luck.. Quote -MichaelC Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.