rcmdesign Posted July 30, 2004 Posted July 30, 2004 I want to display a link in the products description to the category that the product is in. I thought I could go about doing it with <a href="index.php?cPath=$cPath">Link</a> but that doesn't seem to work. Anyone know how to get this link to work?
♥yesudo Posted July 30, 2004 Posted July 30, 2004 as $cPath is a variable you need to echo the value it holds. try: <a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath) . '">' . 'Link' . '</a>'; ?> Your online success is Paramount.
♥yesudo Posted July 30, 2004 Posted July 30, 2004 strange - works here: http://www.cathy-lynn.com/catalog1/product...&products_id=76 click More in this Collection what happened when you tried it ? Your online success is Paramount.
rcmdesign Posted July 30, 2004 Author Posted July 30, 2004 What is the exact code you used there? And did you enter with phpmyadmin?
♥yesudo Posted July 30, 2004 Posted July 30, 2004 nothing done it phpmyadmin. just added this line: <tr> <td class="main"> <?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath) . '">' . 'More in this Collection' . '</a>'; ?> </td></tr> to the product_info.php page. Your online success is Paramount.
rcmdesign Posted July 31, 2004 Author Posted July 31, 2004 Oh ok. I am referring to the product_description because I only want this done in the descrption for certain products. Thanks.
♥yesudo Posted July 31, 2004 Posted July 31, 2004 oki - well you could include it in product_info.php and just IF clause it depending on product_id. depending on how many products you wanted it for. Your online success is Paramount.
rcmdesign Posted July 31, 2004 Author Posted July 31, 2004 That's what I am gonna have to do...Some kind of if statement...
rcmdesign Posted July 31, 2004 Author Posted July 31, 2004 I just realized that code doesn't work if the user searches for the item, or if they select a manufaturer and the item shows up in the results. For some reason it does not pass the cPath parameter when you search for it, or use manufacturer's drop down box. So we would have to put that from that specific product's information in the database. It's category...Any ideas...
rcmdesign Posted July 31, 2004 Author Posted July 31, 2004 Ok here is the fix for that: in products_info.php add somewhere below description: $categories_info_query = tep_db_query("select p2c.categories_id, p2c.products_id, p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = p2c.products_id"); $categories_info = tep_db_fetch_array($categories_info_query); echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $categories_info['categories_id']) . '">' . '<b>Click here to view more products from this category.</b>' . '</a>';
rcmdesign Posted July 31, 2004 Author Posted July 31, 2004 Quick fix to above code - Issue: if customer browses categories in the category box to a particular product, and then clicks the link in the product_info.php page to see other products in that category, it will close up all of the open categories in the includes/boxes/categories.php box. Here is the fix for that: if ($cPath) { echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath) . '">' . '<b>Click here to view more products in this category.</b>' . '</a>'; } else { $categories_info_query = tep_db_query("select p2c.categories_id, p2c.products_id, p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = p2c.products_id"); $categories_info = tep_db_fetch_array($categories_info_query); echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $categories_info['categories_id']) . '">' . '<b>Click here to view more products in this category.</b>' . '</a>'; }
♥yesudo Posted July 31, 2004 Posted July 31, 2004 you can also use: <?php if(isset($cPath) && tep_not_null($cPath)) { ?> <tr> <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath) . '">' . 'More in this Collection' . '</a>'; ?></td></tr> <?php } else { ?> <tr> <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . (int)$HTTP_GET_VARS['manufacturers_id']) . '">' . 'More in this Collection' . '</a>'; ?></td></tr> <?php } ?> Which uses the manufacturer id if cPath is unset. Works for me on both manufacturer and search. Your online success is Paramount.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.