lugobor

Prestashop 1.6 вывод по 4-5 товаров в ряд в категории

Автор
Опубликовано: 154 дня назад (27 декабря 2015)
Рубрика: Prestashop
Редактировалось: 1 раз — 27 декабря 2015
0
Голосов: 0
В Prestashop 1.6 в категории, по умолчанию, выводится 3 товара в ряд (сетка), для увеличения количества товара (в нашем примере - 4 в ряд) надо:

> ваша тема > product_list.tpl
Код PHP:
  1. {if isset($products) && $products}
  2. {*define number of products per line in other page for desktop*}
  3. {if $page_name !='index' && $page_name !='product'}
  4. {assign var='nbItemsPerLine' value=3}
  5. {assign var='nbItemsPerLineTablet' value=2}
  6. {assign var='nbItemsPerLineMobile' value=3}
  7. {else}
  8. {assign var='nbItemsPerLine' value=4}
  9. {assign var='nbItemsPerLineTablet' value=3}
  10. {assign var='nbItemsPerLineMobile' value=2}
  11. {/if}
  12. {*define numbers of product per line in other page for tablet*}
  13. {assign var='nbLi' value=$products|@count}
  14. {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines}
  15. {math equation="nbLi/nbItemsPerLineTablet" nbLi=$nbLi nbItemsPerLineTablet=$nbItemsPerLineTablet assign=nbLinesTablet}
  16. <!-- Products list -->
  17. <ul{if isset($id) && $id} id="{$id}"{/if} class="product_list grid row{if isset($class) && $class} {$class}{/if}">
  18. {foreach from=$products item=product name=products}
  19. {math equation="(total%perLine)" total=$smarty.foreach.products.total perLine=$nbItemsPerLine assign=totModulo}
  20. {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineTablet assign=totModuloTablet}
  21. {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineMobile assign=totModuloMobile}
  22. {if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if}
  23. {if $totModuloTablet == 0}{assign var='totModuloTablet' value=$nbItemsPerLineTablet}{/if}
  24. {if $totModuloMobile == 0}{assign var='totModuloMobile' value=$nbItemsPerLineMobile}{/if}
  25. <li class="ajax_block_product{if $page_name == 'index' || $page_name == 'product'} col-xs-12 col-sm-4 col-md-3{else} col-xs-12 col-sm-6 col-md-4{/if}{if $smarty.foreach.products.iteration%$nbItemsPerLine == 0} last-in-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLine == 1} first-in-line{/if}{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModulo)} last-line{/if}{if $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 0} last-item-of-tablet-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 1} first-item-of-tablet-line{/if}{if $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 0} last-item-of-mobile-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 1} first-item-of-mobile-line{/if}{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModuloMobile)} last-mobile-line{/if}">
заменить на
Код PHP:
  1. {if isset($products) && $products}
  2. {*define number of products per line in other page for desktop*}
  3. {if $page_name !='index' && $page_name !='product'}
  4. {assign var='nbItemsPerLine' value=4}
  5. {assign var='nbItemsPerLineTablet' value=2}
  6. {assign var='nbItemsPerLineMobile' value=3}
  7. {else}
  8. {assign var='nbItemsPerLine' value=4}
  9. {assign var='nbItemsPerLineTablet' value=3}
  10. {assign var='nbItemsPerLineMobile' value=2}
  11. {/if}
  12. {*define numbers of product per line in other page for tablet*}
  13. {assign var='nbLi' value=$products|@count}
  14. {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines}
  15. {math equation="nbLi/nbItemsPerLineTablet" nbLi=$nbLi nbItemsPerLineTablet=$nbItemsPerLineTablet assign=nbLinesTablet}
  16. <!-- Products list -->
  17. <ul{if isset($id) && $id} id="{$id}"{/if} class="product_list grid row{if isset($class) && $class} {$class}{/if}">
  18. {foreach from=$products item=product name=products}
  19. {math equation="(total%perLine)" total=$smarty.foreach.products.total perLine=$nbItemsPerLine assign=totModulo}
  20. {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineTablet assign=totModuloTablet}
  21. {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineMobile assign=totModuloMobile}
  22. {if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if}
  23. {if $totModuloTablet == 0}{assign var='totModuloTablet' value=$nbItemsPerLineTablet}{/if}
  24. {if $totModuloMobile == 0}{assign var='totModuloMobile' value=$nbItemsPerLineMobile}{/if}
  25. <li class="ajax_block_product{if $page_name == 'index' || $page_name == 'product'} col-xs-12 col-sm-4 col-md-3{else} col-xs-12 col-sm-6 col-md-3{/if}{if $smarty.foreach.products.iteration%$nbItemsPerLine == 0} last-in-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLine == 1} first-in-line{/if}{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModulo)} last-line{/if}{if $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 0} last-item-of-tablet-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 1} first-item-of-tablet-line{/if}{if $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 0} last-item-of-mobile-line{elseif $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 1} first-item-of-mobile-line{/if}{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModuloMobile)} last-mobile-line{/if}">
И дальше в global.js меняем бутстраповскую разметку:
строки
Код PHP:
  1. $('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-4').addClass('col-xs-12');
меняем на
Код PHP:
  1. $('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-3').addClass('col-xs-12');
и
Код PHP:
  1. $('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-4');
меняем на
Код PHP:
  1. $('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-3');
Если необходимо сделать, допустим 5 товаров в линию, для col-md даем значение 2, а в tpl файле {assign var='nbItemsPerLine' value= ставим 5} (верхняя часть для отображения в категориях и подкатегориях, нижняя - для главной страницы).
Комментарии (1)
Добавить комментарий   RSS-лента комментариев

Поделиться в соцсетях