OK so this turned out to be really simple to achieve.
Modified : /Modules/HomePageCategories.ascx - to inclued the following,
<asp:DataList ID="dlCategoriesWithProducts" runat="server" RepeatLayout=Flow ItemStyle-CssClass="item-box" RepeatDirection="Vertical" OnItemDataBound="dlCategoriesWithProducts_ItemDataBound">
<ItemTemplate>
<div class="category-item">
<h2 class="title">
<asp:HyperLink ID="hlCategory" runat="server" Text='<%#Server.HtmlEncode(Eval("LocalizedName").ToString()) %>' />
</h2>
<asp:DataList ID="dlProducts" runat="server" RepeatLayout=Flow ItemStyle-CssClass="item-box" RepeatDirection=Horizontal>
<ItemTemplate>
<nopCommerce:ProductBox1 ID="ctrlProductBox" Product='<%# Container.DataItem %>' runat="server" />
</ItemTemplate>
</asp:DataList>
</div>
</ItemTemplate>
</asp:DataList>
Modified: /Modules/HomePageCategories.ascx.cs
protected void BindData()
{
if (SettingManager.GetSettingValueBoolean("Display.CategoriesOnHompageWithProducts") == false)
{
var subCategoryCollection = CategoryManager.GetAllCategoriesDisplayedOnHomePage();
if (subCategoryCollection.Count > 0)
{
dlCategories.DataSource = subCategoryCollection;
dlCategories.DataBind();
}
else
this.Visible = false;
}
else
{
var subCategoryCollection = CategoryManager.GetAllCategoriesDisplayedOnHomePage();
if (subCategoryCollection.Count > 0)
{
dlCategoriesWithProducts.DataSource = subCategoryCollection;
dlCategoriesWithProducts.DataBind();
}
else
this.Visible = false;
}
}
New Sub to handle DataBinding of new DataList:
protected void dlCategoriesWithProducts_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
var category = e.Item.DataItem as Category;
var dlProducts = e.Item.FindControl("dlProducts") as DataList;
string categoryURL = SEOHelper.GetCategoryUrl(category);
if (dlProducts != null)
{
int ProductLimit = SettingManager.GetSettingValueInteger("Display.CategoriesOnHompageWithProducts-PerCategory-ProductCount");
int TotalProducts;
dlProducts.DataSource = ProductManager.GetAllProducts(category.CategoryId, 0, 0, null, ProductLimit, 0, out TotalProducts);
dlProducts.DataBind();
}
HyperLink hlCategory = e.Item.FindControl("hlCategory") as HyperLink;
if (hlCategory != null)
{
hlCategory.NavigateUrl = categoryURL;
}
}
}
I'm loving working with Nopcommerce!