jonquil Posted December 13, 2006 Posted December 13, 2006 I would like to make the Tell a Friend text more specific to the product's category. I have not seen this specific request tackled in the forums. Forgive me if I have missed it. Let's say I have Categories of cars and models of cars as products. Chevys --Camaro --Malibu Fords --Focus --Modeo Tell a Friend shows up on the product Camaro. TAF's generic text in (includes/languages/english.php) is: define('BOX_TELL_A_FRIEND_TEXT', 'Tell someone you know about this product.'); I have already re-defined the text to be 'Tell someone you know about this cool item.' Could someone please help me assemble the right code edit in the correct file to accomplish the following? 'Tell someone you know about this cool [$category]!' All of my categories are plural, ending in "s". For this edit, I need to drop the "s"; otherwise, it becomes: 'Tell someone you now about this cool Chevys' instead of 'this cool Chevy'. Thanks in advance, jon It's all just ones and zeros....
Sandbag Posted December 13, 2006 Posted December 13, 2006 Hi Jon, Here are the instructions for this mod. ------------------------------------------------------- Open catalog\includes\boxes\tell_a_friend.php. 1. After : new infoBoxHeading($info_box_contents, false, false); Add the following : // TELL A FRIEND EDIT START $categories_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCTS_TO_CATEGORIES . " ctp, " . TABLE_PRODUCTS . " p where p.products_id=ctp.products_id and " . "ctp.categories_id=cd.categories_id and p.products_id='" . $HTTP_GET_VARS['products_id'] . "' and cd.language_id='" . (int)$languages_id ."'"); while ($categories = tep_db_fetch_array($categories_query)) { $category_name = $categories['categories_name']; $custom_cat_name = substr($category_name, 0, strlen($category_name)-1); $tell_a_friend_str = BOX_TELL_A_FRIEND_TEXT . " " . $custom_cat_name . "."; } // TELL A FRIEND EDIT END 2. Find the line of code that includes the text BOX_TELL_A_FRIEND_TEXT (not the one in the code above, the other one further down). Replace this BOX_TELL_A_FRIEND_TEXT with: $tell_a_friend_str Save and close the file. 3. Open 'includes/languages/english.php and change define('BOX_TELL_A_FRIEND_TEXT', 'Tell someone you know about this product.'); to define('BOX_TELL_A_FRIEND_TEXT', 'Tell someone you know about this cool'); Save and close the file. 4. You're done! ------------------------------------------------------- Let me know how you get on. Leapfrog - Dynamic Visitor Tracking
jonquil Posted December 13, 2006 Author Posted December 13, 2006 You d'man! Just o-n-e tiny problem. I have "Tell someone you know about this cool Camar" Chevys <--the script should be picking up this cat and minus'ing the s. --Camaro <--the script is actually minus'ing from this subcat; hence "Camar!" --Malibu Fords --Focus --Modeo It DOES work, no doubt about it! Would you tweak it for me? jon It's all just ones and zeros....
Sandbag Posted December 13, 2006 Posted December 13, 2006 Oh right. I think I misunderstood. Are 'Focus', 'Mondeo', etc. sub categories? I thought they were the products. Let me take another look at it. Leapfrog - Dynamic Visitor Tracking
jonquil Posted December 13, 2006 Author Posted December 13, 2006 Subcats. I wasn't clear, very sorry. Cat Fords --Subcat Focus -----product 1 -----product 2 --Subcat Modeo -----product 1 -----product 2 jon It's all just ones and zeros....
Sandbag Posted December 13, 2006 Posted December 13, 2006 OK. Think I've got it. Replace this code with the previous version. You still need to keep the $tell_a_friend_str in place of the BOX_TELL_A_FRIEND_TEXT though. // TELL A FRIEND EDIT START // Get the id of the category this product is filed under $categories_query = tep_db_query("select c.parent_id, ptc.categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc, " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c where p.products_id=ptc.products_id and ptc.categories_id=c.categories_id and p.products_id='" . $HTTP_GET_VARS['products_id'] . "'"); while ($row = tep_db_fetch_array($categories_query)) { $category_info = array('id' => $row['categories_id'], 'parent_id' => $row['parent_id']); } // Navigate up the tree (created in catalog/includes/boxes/categories.php) to find our parent $parent_id = $category_info['id']; while ($parent_id != 0) { $category_name = $tree[$parent_id]['name']; $parent_id = $tree[$parent_id]['parent']; } // Truncate the string by one letter $custom_cat_name = substr($category_name, 0, strlen($category_name)-1); $tell_a_friend_str = BOX_TELL_A_FRIEND_TEXT . " " . $custom_cat_name . "."; // TELL A FRIEND EDIT END Leapfrog - Dynamic Visitor Tracking
jonquil Posted December 13, 2006 Author Posted December 13, 2006 Perfecto! I can't thank you enough :) jon It's all just ones and zeros....
Recommended Posts
Archived
This topic is now archived and is closed to further replies.