Magento Hosted - 更改搜索布局/默认布局

时间:2012-07-20 14:56:52

标签: magento

我想弄清楚如何将默认布局从3列更改为2列。除了搜索结果之外,我已经能够在每个页面上成功完成。我不介意将默认布局更改为2列,因为我希望它们都是统一的。

这是捕获,我在托管解决方案上(我讨厌它,但是,嘿,我只是开发人员)。我无法访问文件系统或单个文件。我还没有找到一种上传和替换任何文件的方法,因此我所做的所有更改都必须从后端完成。我真的希望能做到这一点。

1 个答案:

答案 0 :(得分:0)

答案是,你做不到。简单明了。

但是,你可以使用jQuery破解它,并让它正常工作。这是我使用的代码:

//Check for 3 col layout.
if($j('.col3-layout').length>0){
    //swap the 3 col layout for the 2 col layout
    $j('.col3-layout').addClass('col2-left-layout').removeClass('col3-layout');
    //grab all the code in the wapper, and place it in the main
    var html=$j('.col-wrapper').html();
    $j('.main').html(html);
    //If products are shown as a grid, reorder them.  If it is a list, leave it alone.
    if(!$j('.grid').attr('href')){
        //Grab all items in the list, push them into an array, and then remove all the data.
        var items=new Array();
        $j('.products-grid .item').each(function(){
            items.push($j(this).html());
        });
        $j('.products-grid').remove();
        //build your output
        var html='';
        var gridsize=4; //items per row
        for(var i=0;i<items.length;i++){
            if(i%gridsize==0){//start a new row
                html+='<ul class="products-grid '
                if(i/gridsize==0)//very first row
                    html+='first ';
                else if(i==items.length-gridsize)//last row
                    html+='last '
                if(i/gridsize%2==0)//even class
                    html+='even">';
                else
                    html+='odd">';//odd class
                html+='<li class="item first">'+items[i]+"</li>";
            }else if(i%gridsize==gridsize-1){//very item in row
                html+='<li class="item last">'+items[i]+"</li></ul>";
            }else
                html+='<li class="item">'+items[i]+"</li>";
        }
        $j('.category-products').html(html);  //populate the data.
    }
}