Joomla Templates and Joomla Extensions by JoomlaVision.Com

osCommerce - polska strona wsparcia

Naszą witrynę przegląda teraz 29 gości 

Get Adobe Flash Player

Artykuły w etykiet: produkty
poniedziałek, 17 października 2011 20:47

Wyświetlanie listy produktów w kolumnach

Jeśli chcesz, aby lista produktów w Twoim sklepie wyglądała podobnie do listy nowości ze strony głównej - zastosuj się do tej porady.

Cała sztuka polega na tym, żeby podmienić zawartość pliku includes/modules/product_listing.php.

Domyślnie znajdziecie w nim kod:

testKod: php
  1. <?php
  2. /*
  3.  $Id: product_listing.php 1739 2007-12-20 00:52:16Z hpdl $
  4.  
  5.  osCommerce, Open Source E-Commerce Solutions
  6.  www.oscommerce.com
  7.  
  8.  Copyright (c) 2003 osCommerce
  9.  
  10.  Released under the GNU General Public License
  11. */
  12.  
  13. $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
  14.  
  15. if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
  16. ?>
  17. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  18. <tr>
  19. <td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
  20. <td align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  21. </tr>
  22. </table>
  23. <?php
  24. }
  25.  
  26. $list_box_contents = array();
  27.  
  28. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  29. switch ($column_list[$col]) {
  30. case 'PRODUCT_LIST_MODEL':
  31. $lc_text = TABLE_HEADING_MODEL;
  32. $lc_align = '';
  33. break;
  34. case 'PRODUCT_LIST_NAME':
  35. $lc_text = TABLE_HEADING_PRODUCTS;
  36. $lc_align = '';
  37. break;
  38. case 'PRODUCT_LIST_MANUFACTURER':
  39. $lc_text = TABLE_HEADING_MANUFACTURER;
  40. $lc_align = '';
  41. break;
  42. case 'PRODUCT_LIST_PRICE':
  43. $lc_text = TABLE_HEADING_PRICE;
  44. $lc_align = 'right';
  45. break;
  46. case 'PRODUCT_LIST_QUANTITY':
  47. $lc_text = TABLE_HEADING_QUANTITY;
  48. $lc_align = 'right';
  49. break;
  50. case 'PRODUCT_LIST_WEIGHT':
  51. $lc_text = TABLE_HEADING_WEIGHT;
  52. $lc_align = 'right';
  53. break;
  54. case 'PRODUCT_LIST_IMAGE':
  55. $lc_text = TABLE_HEADING_IMAGE;
  56. $lc_align = 'center';
  57. break;
  58. case 'PRODUCT_LIST_BUY_NOW':
  59. $lc_text = TABLE_HEADING_BUY_NOW;
  60. $lc_align = 'center';
  61. break;
  62. }
  63.  
  64. if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  65. $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
  66. }
  67.  
  68. $list_box_contents[0][] = array('align' => $lc_align,
  69. 'params' => 'class="productListing-heading"',
  70. 'text' => ' ' . $lc_text . ' ');
  71. }
  72.  
  73. if ($listing_split->number_of_rows > 0) {
  74. $rows = 0;
  75. $listing_query = tep_db_query($listing_split->sql_query);
  76. while ($listing = tep_db_fetch_array($listing_query)) {
  77. $rows++;
  78.  
  79. if (($rows/2) == floor($rows/2)) {
  80. $list_box_contents[] = array('params' => 'class="productListing-even"');
  81. } else {
  82. $list_box_contents[] = array('params' => 'class="productListing-odd"');
  83. }
  84.  
  85. $cur_row = sizeof($list_box_contents) - 1;
  86.  
  87. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  88. $lc_align = '';
  89.  
  90. switch ($column_list[$col]) {
  91. case 'PRODUCT_LIST_MODEL':
  92. $lc_align = '';
  93. $lc_text = ' ' . $listing['products_model'] . ' ';
  94. break;
  95. case 'PRODUCT_LIST_NAME':
  96. $lc_align = '';
  97. if (isset($HTTP_GET_VARS['manufacturers_id'])) {
  98. $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
  99. } else {
  100. $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
  101. }
  102. break;
  103. case 'PRODUCT_LIST_MANUFACTURER':
  104. $lc_align = '';
  105. $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';
  106. break;
  107. case 'PRODUCT_LIST_PRICE':
  108. $lc_align = 'right';
  109. if (tep_not_null($listing['specials_new_products_price'])) {
  110. $lc_text = ' <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span>' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
  111. } else {
  112. $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
  113. }
  114. break;
  115. case 'PRODUCT_LIST_QUANTITY':
  116. $lc_align = 'right';
  117. $lc_text = ' ' . $listing['products_quantity'] . ' ';
  118. break;
  119. case 'PRODUCT_LIST_WEIGHT':
  120. $lc_align = 'right';
  121. $lc_text = ' ' . $listing['products_weight'] . ' ';
  122. break;
  123. case 'PRODUCT_LIST_IMAGE':
  124. $lc_align = 'center';
  125. if (isset($HTTP_GET_VARS['manufacturers_id'])) {
  126. $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
  127. } else {
  128. $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
  129. }
  130. break;
  131. case 'PRODUCT_LIST_BUY_NOW':
  132. $lc_align = 'center';
  133. $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
  134. break;
  135. }
  136.  
  137. $list_box_contents[$cur_row][] = array('align' => $lc_align,
  138. 'params' => 'class="productListing-data"',
  139. 'text'  => $lc_text);
  140. }
  141. }
  142.  
  143. new productListingBox($list_box_contents);
  144. } else {
  145. $list_box_contents = array();
  146.  
  147. $list_box_contents[0] = array('params' => 'class="productListing-odd"');
  148. $list_box_contents[0][] = array('params' => 'class="productListing-data"',
  149. 'text' => TEXT_NO_PRODUCTS);
  150.  
  151. new productListingBox($list_box_contents);
  152. }
  153.  
  154. if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
  155. ?>
  156. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  157. <tr>
  158. <td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
  159. <td align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  160. </tr>
  161. </table>
  162. <?php
  163. }
  164. ?>

Należy zamienić go na kod:

testKod: php
  1. <?php
  2. /*
  3.  $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $
  4.  
  5.  osCommerce, Open Source E-Commerce Solutions
  6.  www.oscommerce.com
  7.  
  8.  Copyright (c) 2011 www.oscommerce.info.pl
  9. */
  10. $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
  11. if(($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
  12. ?>
  13. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  14. <tr>
  15. <td align="center"><?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  16. </tr>
  17. <tr>
  18. <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  19. </tr>
  20. </table>
  21. <?php
  22. }
  23. if($listing_split->number_of_rows > 0) {
  24. $listing_query = tep_db_query($listing_split->sql_query);
  25. $row = 0;
  26. $col = 0;
  27. $info_box_contents = array();
  28. while($listing = tep_db_fetch_array($listing_query)) {
  29. if($new_price = tep_get_products_special_price($listing['products_id'])) {
  30. $listing['products_price'] = $new_price;
  31. $info_box_contents[$row][$col] = array('align' => 'center',
  32. 'params' => 'class="smallText" width="33%" valign="top"',
  33. 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH +20, SMALL_IMAGE_HEIGHT +20) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br />' . $currencies->display_price_nodiscount($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])));
  34. } else {
  35. $info_box_contents[$row][$col] = array('align' => 'center',
  36. 'params' => 'class="smallText" width="33%" valign="top"',
  37. 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH +20, SMALL_IMAGE_HEIGHT +20) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br />' . $currencies->display_price($listing['products_id'], $listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])));
  38. }
  39.  
  40. $col ++;
  41. if($col == 4) {
  42. $col = 0;
  43. $row ++;
  44. }
  45. }
  46.  
  47. new contentBox($info_box_contents);
  48.  
  49. } else {
  50. $list_box_contents = array();
  51.  
  52. $list_box_contents[0] = array('params' => 'class="productListing-odd"');
  53. $list_box_contents[0][] = array('params' => 'class="productListing-data"',
  54. 'text' => TEXT_NO_PRODUCTS);
  55.  
  56. new productListingBox($list_box_contents);
  57. }
  58. if(($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
  59. ?>
  60. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  61. <tr>
  62. <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  63. </tr>
  64. <tr>
  65. <td align="center"><?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  66. </tr>
  67. </table>
  68. <?php
  69. }
  70. ?>

i mamy zmienione wyświetlanie listy produktów.

Dodatkowe informacje

  • Wersja skepu osCommerce Merchant rc2.2, Proffesional 1.0.3
  • Dostępne wersje językowe Polska, Angielska
Opublikowane w Tips & tricks

Logowanie

Nasze sondy

Czy podoba ci się nowa odsłona strony?
 
Money.pl - wiadomości, notowania, giełda, kursy walut
NBP 2012-05-18
USD 3,4431 +0,69%
EUR 4,3683 +0,44%
CHF 3,6371 +0,44%
GBP 5,4356 +0,03%
Money.pl - Kliknij po więcej
20 maja 2012
Źródło: MeteoGroup