ryanf Posted June 9, 2004 Share Posted June 9, 2004 Hey, I am currently trying to do some seo and I was thinking of alt tags. Rightnow, when the product image is displayed the alt tag is the name of the products. For me that isn't too good since the name and model are something like 16A44A which doesn't help much. I was thinking if there was a way you could have the alt tag be the products category. So for 16A44A for example the alt tag would be rings or even better the sub category color stone rings. If the product is not located in a sub category, then it just shows the category for the alt tag. Anyone got any ideas if this is possible or even worth it?!? Thanks Ryan If I was crafty, this would be a funny signature. Link to comment Share on other sites More sharing options...
Acheron Posted June 9, 2004 Share Posted June 9, 2004 in catalog/product_info.php ... FIND: tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']) This bit: addslashes($product_info['products_name']) would need to be changed obviously, as that's your alt tag. Just took a quick look but here's how I would do it: - add query like 'SELECT categories_id FROM products_to_categories WHERE products_id = $product_info['products_id'] - create new variable $X from result - add query like 'SELECT categories_name FROM categories_description table WHERE categories_id = $X - create variable $Y based on that result - use $Y as your alt tag for the image on that page - repeat the process as necessary to change any alt tags you want to change Link to comment Share on other sites More sharing options...
ryanf Posted June 9, 2004 Author Share Posted June 9, 2004 Thanks for the code. I got it to work and this is what I used for the code $product_category = tep_db_query("select cd.categories_name, cd.categories_id from " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE pc.categories_id = cd.categories_id and pc.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); $alt_tag = tep_db_fetch_array($product_category); Now, how can I get the parent category name? I want to combine the two if there is a parent so for example on my website I have Rings -> Anniversary Rings -> Bead Set for categories so when I hover over the image the alt tag of a product in the bead set category should be "Bead Set Anniversary Rings" I guess I would only want that if the categories went three deep. Other wise I would just want the one categories name, since if there was no bead set category, the alt tag "anniversary rings rings" would look funny. Any one know how to get the parents categorie id and how many levels deep you are? Ryan. If I was crafty, this would be a funny signature. Link to comment Share on other sites More sharing options...
ryanf Posted June 9, 2004 Author Share Posted June 9, 2004 Never mind I figured it out. Here is the code I used: $alt_tag = tep_db_fetch_array($product_category); $filename = explode("_",$cPath); $i = 0; while ($filename[$i]) { $i++; } if ($i == 3) { $p_category = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " WHERE categories_id = " . $filename[1] . ""); $catname = tep_db_fetch_array($p_category); $alttag = $alt_tag['categories_name'] . ' ' . $catname['categories_name']; } else { $alttag = $alt_tag['categories_name']; } Then where I saw $product_info['products_name'] I just changed it to $alttag Ryan If I was crafty, this would be a funny signature. Link to comment Share on other sites More sharing options...
koie Posted August 7, 2004 Share Posted August 7, 2004 Whoeps...wrong topic posting.. Please remove Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.