我知道在catalog.xml中这行会影响所有布局:
<action method="setColumnCount"><columns>5</columns></action>
Run Code Online (Sandbox Code Playgroud)
但我想根据特定的页面布局更改列数,即:2栏左栏,3栏等.
这是有人说要做的,但我不确定我是否在正确的位置添加更新标签,因为它似乎不起作用.此外,如果您在重新启用缓存后阅读他们所说的评论,则会打破它:http: //www.lotusseedsdesign.com/blog/change-grid-view-column-4-product-listing
那么有谁知道如何使用addColumnCountLayoutDepend方法或任何其他方式来更改特定于页面布局的产品网格上的列数?
对于子类别页面,在app/design/frontend /您的Interface/layout/catalog.xml中更改列值为以下行:
<action method="setColumnCount"><columns>4</columns></action>
Run Code Online (Sandbox Code Playgroud)
对于根类别页面,在app/design/frontend /您的Interface/template/catalog/product/list.phtml中,在"网格模式"部分中找到以下代码,并使用适当的值进行更改:
<?php $_columnCount = $this->getColumnCount(); ?>
Run Code Online (Sandbox Code Playgroud)
喜欢
<?php $_columnCount = 4; ?>
Run Code Online (Sandbox Code Playgroud)
有点老问题(差不多3年:D)但我在Kathir'Sid'Vel的网站上找到了一个有趣的解决方案
为此,您将编辑catalog/product/list.phtml模板.
找到行:
<?php $_columnCount = $this->getColumnCount(); ?>
Run Code Online (Sandbox Code Playgroud)
并用下面的代码替换或注释该行并在其后添加代码.
<?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 = 4;
break;
case 'page/2columns-left.phtml':
$_columnCount = 3;
break;
case 'page/2columns-right.phtml':
$_columnCount = 3;
break;
case 'page/3columns.phtml':
$_columnCount = 2;
break;
default:
$_columnCount = 3;
break;
}
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17969 次 |
| 最近记录: |