Show more than one column of search results

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 年 前
Hi there

I am trying to show a list of 4 products across when somebody searches but for some reason i only get one column of 1 product.

Could someone help?

Thanks
11 年 前
you need to modify search.cshtml in Presentation/Nop.Web/Views/Catalog/ folder .

in line no. 144 you will find the following code.

 @foreach (var product in Model.Products)
                {
                    <div class="item-box">
                        @Html.Partial("_ProductBox", product)
                    </div>
                }


change this to


@(Html.DataList<SearchModel>(Model, 3,
<div class="item-box">
                        @Html.Partial("_ProductSmallBox", product)
                    </div>
))


Instead of using _ProductSmallBox you can use your own customized views too.
here number 3 means three columns. you can change to any number as per your need.

http://www.elaamart.com
11 年 前
thanks
11 年 前
Hi

I want to achieve the same effect, but get the following error:

'System.Web.Mvc.HtmlHelper<Nop.Web.Models.Catalog.SearchModel>' does not contain a definition for 'DataList' and the best extension method overload 'Nop.Web.Framework.UI.DataListExtensions.DataList<T>(System.Web.Mvc.HtmlHelper, System.Collections.Generic.IEnumerable<T>, int, System.Func<T,System.Web.WebPages.HelperResult>)' has some invalid arguments

I'm using 2.6, do I need to change anything?

Thanks
Adam
11 年 前
S'okay, solved it by using

<div class="product-grid">
                @(Html.DataList<ProductOverviewModel>(Model.Products, 4,
                    @<div class="item-box">
                        @Html.Partial("_ProductBox", @item)
                    </div>
                ))
            </div>

Cheers
11 年 前
i have tried all codes but keep getting an error. Any idea's
11 年 前
Can anyone help on this?

Thanks
Mike
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.