mark27uk3 Posted August 28, 2005 Share Posted August 28, 2005 Hi, Is anyone able to tell me which contrib this is, I have looked through the contribs but no joy. Thanks Mark Lifes a bitch, then you marry one, then you die! Link to comment Share on other sites More sharing options...
stevel Posted August 28, 2005 Share Posted August 28, 2005 Could be just a simple modification of an existing contrib. Once you know how to get the product list, formatting into columns like this isn't hard. Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
mark27uk3 Posted August 28, 2005 Author Share Posted August 28, 2005 Hi Steve, I have stripped the all_products contrib down to remove the categories and just leave a list of products. Any chance you could have a go at making it two columns for me. <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table width="100%" cellspacing="0" cellpadding=0" border="0"> <?php $products_query = tep_db_query("SELECT p.products_id, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = FLOOR($languages_id) ORDER BY pc.categories_id, pd.products_name"); while($products = tep_db_fetch_array($products_query)) { echo " <tr>\n" . ' <td class="smallText"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id'] . (($language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $language_code))) . '">' . $products['products_name'] . "</a></td>\n" . " </tr>\n"; } ?> </table></td> </tr> <tr> <td align="left" class="smallText"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> </tr> </table></td> <!-- body_text_eof //--> Thanks Mark Lifes a bitch, then you marry one, then you die! Link to comment Share on other sites More sharing options...
stevel Posted August 28, 2005 Share Posted August 28, 2005 What you need to do is get the count of products, divide by two. Start the column, and when you've put out half, emit </td><td> and continue with the other half. If you have an odd number of products, the right column will have one more entry. The way I'd approach this is to get the halfway point, subtract one each time, and when it reaches exactly zero, split the column. Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
mark27uk3 Posted August 28, 2005 Author Share Posted August 28, 2005 I have no idea on how to do that! Lifes a bitch, then you marry one, then you die! Link to comment Share on other sites More sharing options...
stevel Posted August 28, 2005 Share Posted August 28, 2005 Time you learned, then. You can see lots of examples of this sort of thing elsewhere in osC. Pick up a book on PHP, such as "Programming PHP" from O'Reilly Press and study it. You'll need basic PHP skills to get anywhere with osC. Here's my take on it. based on what you started with - not tested. <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table width="100%" cellspacing="0" cellpadding=0" border="0"> <?php $products_query = tep_db_query("SELECT count(*) as total FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = FLOOR($languages_id)"); $colitems = (int)($products_query['total'] / 2); $products_query = tep_db_query("SELECT p.products_id, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = FLOOR($languages_id) ORDER BY pc.categories_id, pd.products_name"); while($products = tep_db_fetch_array($products_query)) { echo " <tr>\n" . ' <td class="smallText"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id'] . (($language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $language_code))) . '">' . $products['products_name'] . "</a></td>\n" . " </tr>\n"; } if (--$colitems == 0) echo "</td><td>\n"; ?> </table></td> </tr> <tr> <td align="left" class="smallText"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> </tr> </table></td> <!-- body_text_eof //--> Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
stevel Posted August 28, 2005 Share Posted August 28, 2005 Your formatting is off, I think - and so was my code. Try this, which I did test: <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table width="100%" cellspacing="0" cellpadding=0" border="0"> <tr><td class="smalltext"> <?php $products_query = tep_db_query("SELECT count(*) as total FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = FLOOR($languages_id)"); $products_check = tep_db_fetch_array($products_query); $colitems = (int)($products_check['total'] / 2); $products_query = tep_db_query("SELECT p.products_id, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = FLOOR($languages_id) ORDER BY pc.categories_id, pd.products_name"); while($products = tep_db_fetch_array($products_query)) { echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id'] . (($language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $language_code))) . '">' . $products['products_name'] . "</a><br>\n"; if (--$colitems == 0) echo '</td><td class="smalltext">'; } ?> </td></tr></table></td> </tr> <tr> <td align="left" class="smallText"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> </tr> </table></td> <!-- body_text_eof //--> Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
mark27uk3 Posted August 28, 2005 Author Share Posted August 28, 2005 Hi Steve, Thanks for that, I do know a little php which I have learnt from studying the osc code. Its just the code that I have never come across before that I struggle with. I will definately get that book you recommended. I did change one line in the code because the formating showed the left column further down the page to the right column. I changed this if (--$colitems == 0) echo '</td><td class="smalltext">'; to this if (--$colitems == -15) echo '</td><td class="smalltext">'; Probably not the right way to do it but it evened the columns up. Mark Lifes a bitch, then you marry one, then you die! Link to comment Share on other sites More sharing options...
stevel Posted August 28, 2005 Share Posted August 28, 2005 I can't imagine why, but whatever works for you... Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
gregy Posted October 26, 2007 Share Posted October 26, 2007 any chances to get displayed only last 10 added? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.