【问题标题】:How to have different amount of products per row, different in each page layout如何每行有不同数量的产品,每个页面布局都不同
【发布时间】:2014-09-29 21:34:09
【问题描述】:

https://magento.stackexchange.com/questions/12899/display-more-items-per-row-in-products-page

^ 这篇文章是每行设置 4 个产品的指南 |对于所有页面。

我想为每个页面布局设置不同数量的产品。

目标:

  • 每行 3 个产品,用于 3 列页面布局
  • 每行 4 个产品,用于 2 列 ^
  • 每行 5 个产品,用于 1 列 ^

请给出每行定制产品的说明。

【问题讨论】:

    标签: magento


    【解决方案1】:

    在 app/design/frontend/yourtheme/default/template/catalog/product/list.phtml 中(如果您没有从 app/design/frontend/base/default/template/catalog/product/ 复制,请创建它list.phtml) 并替换该行:

    <?php // Grid Mode ?>
    
    <?php $_collectionSize = $_productCollection->count() ?>
    <?php $_columnCount = $this->getColumnCount(); ?>
    <?php $i=0; foreach ($_productCollection as $_product): ?>
    

    <?php $_collectionSize = $_productCollection->count() ?>
    
    <?php
    
    // Get the layout's page template
    $pageLayoutRootTemplate = $this->getLayout()->getBlock('root')->getTemplate();
    // Set the column count based on the layout template used
    switch ($pageLayoutRootTemplate) {
        case 'page/1column.phtml':
            $_columnCount = 5;
            break;
        case 'page/2columns-left.phtml':
            $_columnCount = 4;
            break;
        case 'page/2columns-right.phtml':
            $_columnCount = 4;
            break;
        case 'page/3columns.phtml':
            $_columnCount = 3;
            break;
        default:
            $_columnCount = 3;
            break;
    }
    // comment normal line out $_columnCount = $this->getColumnCount(); ?>
    
    <?php $i=0; foreach ($_productCollection as $_product): ?>
    

    显然将其修改为您想要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-04
      • 1970-01-01
      • 1970-01-01
      • 2013-11-12
      • 2011-06-14
      • 2012-10-24
      相关资源
      最近更新 更多