Skip to content

Commit 8ee65c5

Browse files
committed
Theming: settings & more
1 parent 828f458 commit 8ee65c5

16 files changed

Lines changed: 105 additions & 16 deletions

File tree

src/Libraries/SmartStore.Core/Domain/Catalog/CatalogSettings.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ public enum SubCategoryDisplayType
1010
Bottom = 10
1111
}
1212

13+
public enum GridColumnSpan
14+
{
15+
Max2Cols = 2,
16+
Max3Cols = 3,
17+
Max4Cols = 4,
18+
Max5Cols = 5,
19+
Max6Cols = 6
20+
}
21+
1322
public class CatalogSettings : ISettings
1423
{
1524
public CatalogSettings()
@@ -53,6 +62,7 @@ public CatalogSettings()
5362
DisplayAllImagesNumber = 6;
5463
ShowShortDescriptionInGridStyleLists = true;
5564
ShowManufacturerInGridStyleLists = true;
65+
ShowManufacturerLogoInLists = false;
5666
ShowProductOptionsInLists = true;
5767
ShowColorSquaresInLists = true;
5868
ShowDiscountSign = true;
@@ -64,6 +74,7 @@ public CatalogSettings()
6474
MostRecentlyUsedCategoriesMaxSize = 6;
6575
MostRecentlyUsedManufacturersMaxSize = 4;
6676
IncludeShortDescriptionInCompareProducts = true;
77+
GridStyleListColumnSpan = GridColumnSpan.Max4Cols;
6778
}
6879

6980
/// <summary>
@@ -345,6 +356,11 @@ public CatalogSettings()
345356

346357
public bool ShowManufacturerInGridStyleLists { get; set; }
347358

359+
/// <summary>
360+
/// Whether to show brand logo instead of textual name in product lists
361+
/// </summary>
362+
public bool ShowManufacturerLogoInLists { get; set; }
363+
348364
public bool ShowShortDescriptionInGridStyleLists { get; set; }
349365

350366
public bool ShowProductOptionsInLists { get; set; }
@@ -448,5 +464,10 @@ public CatalogSettings()
448464
/// Gets or sets how many items to display maximally in the most recently used manufacturer list
449465
/// </summary>
450466
public int MostRecentlyUsedManufacturersMaxSize { get; set; }
467+
468+
/// <summary>
469+
/// Gets or sets how many columns per row should be displayed at most in grid style lists on largest screen resolution.
470+
/// </summary>
471+
public GridColumnSpan GridStyleListColumnSpan { get; set; }
451472
}
452473
}

src/Libraries/SmartStore.Data/Migrations/MigrationsConfiguration.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,16 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
221221
"Legt fest, ob die Produkt-Kurzbeschreibung auch in Produktlisten angezeigt werden sollen");
222222

223223
builder.AddOrUpdate("Admin.Configuration.Settings.Catalog.ShowManufacturerInGridStyleLists",
224-
"Show manufacturer in product lists",
225-
"Zeige Hersteller in Produktlisten",
226-
"Specifies whether the manufacturer name should be displayed in grid style product lists",
227-
"Legt fest, ob der Hersteller-Name auch in Rasterstil Produktlisten angezeigt werden sollen");
224+
"Show brand in product lists",
225+
"Zeige Hersteller/Marke in Produktlisten",
226+
"Specifies whether the brand name should be displayed in grid style product lists",
227+
"Legt fest, ob der Markenname auch in Rasterstil Produktlisten angezeigt werden sollen");
228+
229+
builder.AddOrUpdate("Admin.Configuration.Settings.Catalog.ShowManufacturerLogoInLists",
230+
"Show brand logo instead of name",
231+
"Zeige Marken-Logo statt -Name",
232+
"Specifies whether the brand logo should be displayed in line style product lists. Falls back to textual name if no logo has been uploaded.",
233+
"Legt fest, ob das Marken-Logo in Produktlisten dargestellt werden soll (nicht anwendbar in Rasteransicht). Wenn kein Logo hochgeladen wurde, wird grundsätzlich der Name angezeigt.");
228234

229235
builder.AddOrUpdate("Admin.Configuration.Settings.Catalog.ShowProductOptionsInLists",
230236
"Show variant names in product lists",
@@ -267,6 +273,7 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
267273

268274
builder.AddOrUpdate("Products.Price.OldPrice", "Regular", "Regulär");
269275
builder.AddOrUpdate("Products.Sku", "SKU", "Art.-Nr.");
276+
builder.AddOrUpdate("Products.ChooseColorX", "Choose {0}", "{0} auswählen");
270277

271278

272279
builder.AddOrUpdate("Tax.LegalInfoShort", "Prices {0}, plus <a href='{1}'>shipping</a>", "Preise {0}, zzgl. <a href='{1}'>Versandkosten</a>");
@@ -292,6 +299,18 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
292299

293300
builder.AddOrUpdate("Media.Manufacturer.ImageLinkTitleFormat", "All products from {0}", "Alle Produkte von {0}");
294301
builder.AddOrUpdate("Manufacturers.List", "All Brands", "Alle Marken");
302+
303+
builder.AddOrUpdate("Admin.Configuration.Settings.Catalog.GridStyleListColumnSpan",
304+
"Products per row in grid style list",
305+
"Anzahl Produkte pro Zeile in Rasteransicht",
306+
"Sets the responsive behavior of the grid style product list. The wider the screen, the more products are arranged in a row.",
307+
"Legt das responsive Verhalten der Produktliste in der Rasteransicht fest. Je breiter der Bildschirm, desto mehr Produkte werden in einer Zeile angeordnet.");
308+
309+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.Catalog.GridColumnSpan.Max2Cols", "Always 2 (mobile & desktop) -not recommended", "Immer 2 (Mobil & Desktop) - nicht empfohlen");
310+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.Catalog.GridColumnSpan.Max3Cols", "2 (mobile) to 3 (desktop)", "2 (Mobil) bis 3 (Desktop)");
311+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.Catalog.GridColumnSpan.Max4Cols", "2 (mobile) to 4 (desktop) - recommended", "2 (Mobil) bis 4 (Desktop) - empfohlen");
312+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.Catalog.GridColumnSpan.Max5Cols", "2 (mobile) to 5 (desktop)", "2 (Mobil) bis 5 (Desktop)");
313+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.Catalog.GridColumnSpan.Max6Cols", "2 (mobile) to 6 (desktop)", "2 (Mobil) bis 6 (Desktop)");
295314
}
296315
}
297316
}

src/Presentation/SmartStore.Web.Framework/Extensions/HtmlExtensions.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,20 @@ public static MvcHtmlString SettingEditorFor<TModel, TValue>(
603603
object additionalViewData = null)
604604
{
605605
var checkbox = helper.SettingOverrideCheckbox(expression, parentSelector);
606-
var editor = helper.EditorFor(expression, additionalViewData);
606+
var editor = helper.EditorFor(expression, additionalViewData);
607+
608+
return MvcHtmlString.Create(checkbox.ToString() + editor.ToString());
609+
}
610+
611+
public static MvcHtmlString EnumSettingEditorFor<TModel, TValue>(
612+
this HtmlHelper<TModel> helper,
613+
Expression<Func<TModel, TValue>> expression,
614+
string parentSelector = null,
615+
object htmlAttributes = null,
616+
string optionLabel = null) where TValue : struct
617+
{
618+
var checkbox = helper.SettingOverrideCheckbox(expression, parentSelector);
619+
var editor = helper.DropDownListForEnum(expression, htmlAttributes, optionLabel);
607620

608621
return MvcHtmlString.Create(checkbox.ToString() + editor.ToString());
609622
}

src/Presentation/SmartStore.Web.Framework/Theming/ThemeHtmlExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static MvcHtmlString ThemeVarSelectEditor(HtmlHelper html, ThemeVariable
108108
select new SelectListItem
109109
{
110110
Value = x,
111-
Text = x, // TODO: (MC) Localize
111+
Text = x, // TODO: (mc) Localize
112112
Selected = x.IsCaseInsensitiveEqual(value)
113113
};
114114

src/Presentation/SmartStore.Web/Administration/Controllers/SettingController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ public ActionResult Catalog()
580580
var deliveryTimes = _deliveryTimesService.GetAllDeliveryTimes();
581581
foreach (var dt in deliveryTimes)
582582
{
583-
model.AvailableDeliveryTimes.Add(new SelectListItem()
583+
model.AvailableDeliveryTimes.Add(new SelectListItem
584584
{
585585
Text = dt.Name,
586586
Value = dt.Id.ToString(),
@@ -597,7 +597,7 @@ public ActionResult Catalog(CatalogSettingsModel model, FormCollection form)
597597
if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageSettings))
598598
return AccessDeniedView();
599599

600-
//load settings for a chosen store scope
600+
// Load settings for a chosen store scope
601601
var storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext);
602602
var catalogSettings = _services.Settings.LoadSetting<CatalogSettings>(storeScope);
603603
catalogSettings = model.ToEntity(catalogSettings);

src/Presentation/SmartStore.Web/Administration/Models/Settings/CatalogSettingsModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ public CatalogSettingsModel()
147147
public PriceDisplayType PriceDisplayType { get; set; }
148148
public SelectList AvailablePriceDisplayTypes { get; set; }
149149

150+
[SmartResourceDisplayName("Admin.Configuration.Settings.Catalog.GridStyleListColumnSpan")]
151+
public GridColumnSpan GridStyleListColumnSpan { get; set; }
152+
150153
#endregion
151154

152155
#region Products
@@ -157,6 +160,9 @@ public CatalogSettingsModel()
157160
[SmartResourceDisplayName("Admin.Configuration.Settings.Catalog.ShowManufacturerInGridStyleLists")]
158161
public bool ShowManufacturerInGridStyleLists { get; set; }
159162

163+
[SmartResourceDisplayName("Admin.Configuration.Settings.Catalog.ShowManufacturerLogoInLists")]
164+
public bool ShowManufacturerLogoInLists { get; set; }
165+
160166
[SmartResourceDisplayName("Admin.Configuration.Settings.Catalog.ShowProductOptionsInLists")]
161167
public bool ShowProductOptionsInLists { get; set; }
162168

src/Presentation/SmartStore.Web/Administration/Views/Setting/Catalog.cshtml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,15 @@
486486
@Html.ValidationMessageFor(model => model.DefaultViewMode)
487487
</td>
488488
</tr>
489+
<tr>
490+
<td class="adminTitle">
491+
@Html.SmartLabelFor(model => model.GridStyleListColumnSpan)
492+
</td>
493+
<td class="adminData">
494+
@Html.EnumSettingEditorFor(model => model.GridStyleListColumnSpan)
495+
@Html.ValidationMessageFor(model => model.GridStyleListColumnSpan)
496+
</td>
497+
</tr>
489498
<tr>
490499
<td class="adminTitle">
491500
@Html.SmartLabelFor(model => model.DefaultSortOrder)
@@ -570,6 +579,15 @@
570579
@Html.ValidationMessageFor(model => model.ShowManufacturerInGridStyleLists)
571580
</td>
572581
</tr>
582+
<tr>
583+
<td class="adminTitle">
584+
@Html.SmartLabelFor(model => model.ShowManufacturerLogoInLists)
585+
</td>
586+
<td class="adminData">
587+
@Html.SettingEditorFor(model => model.ShowManufacturerLogoInLists)
588+
@Html.ValidationMessageFor(model => model.ShowManufacturerLogoInLists)
589+
</td>
590+
</tr>
573591
<tr>
574592
<td class="adminTitle">
575593
@Html.SmartLabelFor(model => model.ShowBasePriceInProductLists)

src/Presentation/SmartStore.Web/Controllers/CatalogHelper.MapProduct.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public virtual ProductSummaryModel MapProductSummaryModel(IPagedList<Product> pr
208208
var model = new ProductSummaryModel(products)
209209
{
210210
ViewMode = settings.ViewMode,
211+
GridColumnSpan = _catalogSettings.GridStyleListColumnSpan,
211212
ShowSku = _catalogSettings.ShowProductSku,
212213
ShowWeight = _catalogSettings.ShowWeight,
213214
ShowDimensions = settings.MapDimensions,
@@ -256,6 +257,10 @@ public virtual ProductSummaryModel MapProductSummaryModel(IPagedList<Product> pr
256257

257258
scope.Commit();
258259

260+
// don't show stuff without data at all
261+
model.ShowDescription = model.ShowDescription && model.Items.Any(x => x.ShortDescription.HasValue());
262+
model.ShowBrand = model.ShowBrand && model.Items.Any(x => x.Manufacturer != null);
263+
259264
return model;
260265
}
261266
}
@@ -310,6 +315,7 @@ from a in colorAttribute.ProductVariantAttributeValues.Take(20)
310315
where (a.ColorSquaresRgb.HasValue() && !a.ColorSquaresRgb.IsCaseInsensitiveEqual("transparent"))
311316
select new ProductSummaryModel.ColorAttributeValue
312317
{
318+
Id = a.Id,
313319
Color = a.ColorSquaresRgb,
314320
Alias = a.Alias,
315321
FriendlyName = a.GetLocalized(l => l.Name)
@@ -395,8 +401,7 @@ from a in colorAttribute.ProductVariantAttributeValues.Take(20)
395401
item.Manufacturer = PrepareManufacturersOverviewModel(
396402
ctx.BatchContext.ProductManufacturers.GetOrLoad(product.Id),
397403
ctx.CachedManufacturerModels,
398-
settings.ViewMode == ProductSummaryViewMode.List /*_catalogSettings.ShowManufacturerPicturesInProductDetail*/).FirstOrDefault();
399-
// TODO: (mc) _catalogSettings.ShowManufacturerPicturesInProductDetail > ShowManufacturerPicturesInProductLists (new setting)
404+
_catalogSettings.ShowManufacturerLogoInLists && settings.ViewMode == ProductSummaryViewMode.List).FirstOrDefault();
400405
}
401406

402407
// Spec Attributes

src/Presentation/SmartStore.Web/Controllers/ProductController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ public ActionResult CrossSellProducts(int? productThumbPictureSize)
405405

406406
var products = _productService.GetCrosssellProductsByShoppingCart(cart, _shoppingCartSettings.CrossSellsNumber);
407407

408-
//ACL and store mapping
408+
// ACL and store mapping
409409
products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList();
410410

411411
if (products.Any())

src/Presentation/SmartStore.Web/Models/Catalog/IListActions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using System;
22
using System.Collections.Generic;
33
using SmartStore.Core;
4+
using SmartStore.Core.Domain.Catalog;
45

56
namespace SmartStore.Web.Models.Catalog
67
{
78
public interface IListActions
89
{
910
ProductSummaryViewMode ViewMode { get; }
11+
GridColumnSpan GridColumnSpan { get; }
1012
bool AllowViewModeChanging { get; }
1113

1214
bool AllowFiltering { get; }

0 commit comments

Comments
 (0)