Skip to content

Commit 09851b0

Browse files
committed
Rendering component - issue #22
1 parent b26a2a5 commit 09851b0

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@inherits Umbraco.Web.Mvc.UmbracoViewPage<List<Umbraco.Cms.Integrations.Commerce.Shopify.Models.ViewModels.ProductViewModel>>
2+
3+
<dl class="products-list">
4+
@foreach (var product in Model)
5+
{
6+
<dt class="product-title">@product.Title</dt>
7+
<dd class="product-body">@Html.Raw(product.Body)</dd>
8+
<img class="product-image" src="@product.Image" alt="@product.Title" />
9+
}
10+
</dl>
11+
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<List<Umbraco.Cms.Integrations.Commerce.Shopify.Models.ViewModels.ProductViewModel>>
2+
3+
<dl class="products-list">
4+
@foreach (var product in Model)
5+
{
6+
<dt class="product-title">@product.Title</dt>
7+
<dd class="product-body">@Html.Raw(product.Body)</dd>
8+
<img class="product-image" src="@product.Image" alt="@product.Title" />
9+
}
10+
</dl>
11+
12+
13+

src/Umbraco.Cms.Integrations.Commerce.Shopify/Constants.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ public static class Constants
1414

1515
public const string AppPluginFolderPath = "~/App_Plugins/UmbracoCms.Integrations/Commerce/Shopify";
1616

17+
public static class RenderingComponent
18+
{
19+
public const string DefaultV8ViewPath = AppPluginFolderPath + "/Render/Products.cshtml";
20+
21+
public const string DefaultV9ViewPath = AppPluginFolderPath + "/Render/ProductsV9.cshtml";
22+
}
23+
1724
public static class Configuration
1825
{
1926
public const string Settings = "Umbraco:Cms:Integrations:Commerce:Shopify:Settings";

src/Umbraco.Cms.Integrations.Commerce.Shopify/Helpers/HtmlHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ namespace Umbraco.Cms.Integrations.Commerce.Shopify.Helpers
1717
public static class ShopifyHtmlExtensions
1818
{
1919
#if NETCOREAPP
20-
public static IHtmlContent RenderShopifyProductsList(this HtmlHelper htmlHelper, List<ProductViewModel> vm)
20+
public static IHtmlContent RenderShopifyProductsList(this IHtmlHelper<dynamic> htmlHelper, List<ProductViewModel> vm, string renderingViewPath = "")
2121
{
22-
return htmlHelper.Partial($"{Constants.AppPluginFolderPath}/Render/Products.cshtml", vm);
22+
return htmlHelper.Partial(string.IsNullOrEmpty(renderingViewPath) ? Constants.RenderingComponent.DefaultV9ViewPath : renderingViewPath, vm);
2323
}
2424
#else
25-
public static IHtmlString RenderShopifyProductsList(this HtmlHelper htmlHelper, List<ProductViewModel> vm)
25+
public static IHtmlString RenderShopifyProductsList(this HtmlHelper htmlHelper, List<ProductViewModel> vm, string renderingViewPath = "")
2626
{
27-
return htmlHelper.Partial($"{Constants.AppPluginFolderPath}/Render/Products.cshtml", vm);
27+
return htmlHelper.Partial(string.IsNullOrEmpty(renderingViewPath) ? Constants.RenderingComponent.DefaultV8ViewPath : renderingViewPath, vm);
2828
}
2929
#endif
3030
}

0 commit comments

Comments
 (0)