2012-07-20 91 views
0

我想弄清楚如何將默認佈局從3列更改爲2列。除了搜索結果,我已經能夠在每個頁面上成功地完成它。我不介意將默認佈局更改爲2列,因爲我希望它們都是統一的。Magento託管 - 更改搜索佈局/默認佈局

下面是捕獲,我在一個託管的解決方案(我討厭它,但嘿,我只是開發人員)。我無法訪問文件系統或單個文件。我還沒有想出一種方法來上傳和替換任何文件,因此我所做的所有更改都必須從後端完成。我真的希望這可以做到。

+0

我不認爲這是可能的,如果不修改layout.xml文件,可能想弄清楚如何編輯這些文件。 – B00MER 2012-07-20 15:56:51

+0

@ B00MER我們支付Magento來託管它,這也讓我們獲得他們的支持,所以我可能也會在那裏打開票。只是想知道有沒有辦法,有人會知道。 – 2012-07-20 16:04:42

回答

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. 
    } 
}