Skip to content

Commit

Permalink
Dev-Tools: Added a widget sample
Browse files Browse the repository at this point in the history
  • Loading branch information
mgesing committed Mar 10, 2018
1 parent 9addee8 commit 4066c68
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
Expand Up @@ -79,6 +79,11 @@ public ActionResult ProductEditTab(int productId, FormCollection form)
var result = PartialView(model);
result.ViewData.TemplateInfo = new TemplateInfo { HtmlFieldPrefix = "CustomProperties[DevTools]" };
return result;
}
}
}

public ActionResult MyDemoWidget()
{
return Content("Hello world! This is a sample widget created for demonstration purposes by Dev-Tools plugin.");
}
}
}
27 changes: 23 additions & 4 deletions src/Plugins/SmartStore.DevTools/DevToolsPlugin.cs
@@ -1,17 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Routing;
using SmartStore.Core.Logging;
using SmartStore.Core.Plugins;
using SmartStore.Data;
using SmartStore.Data.Setup;
using SmartStore.Services.Cms;
using SmartStore.Services.Common;
using SmartStore.Services.Configuration;

namespace SmartStore.DevTools
{
public class DevToolsPlugin : BasePlugin, IConfigurable
{
[DisplayOrder(10)]
[SystemName("Widgets.DevToolsDemo")]
[FriendlyName("Dev-Tools Demo Widget")]
public class DevToolsPlugin : BasePlugin, IConfigurable, IWidget
{
private readonly ISettingService _settingService;

public DevToolsPlugin(ISettingService settingService)
Expand All @@ -22,7 +27,21 @@ public DevToolsPlugin(ISettingService settingService)

public ILogger Logger { get; set; }

public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
public IList<string> GetWidgetZones() => new List<string> { "home_page_top" };

public void GetDisplayWidgetRoute(string widgetZone, object model, int storeId, out string actionName, out string controllerName, out RouteValueDictionary routeValues)
{
actionName = "MyDemoWidget";
controllerName = "DevTools";

routeValues = new RouteValueDictionary
{
{ "Namespaces", "SmartStore.DevTools.Controllers" },
{ "area", "SmartStore.DevTools" }
};
}

public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
{
actionName = "Configure";
controllerName = "DevTools";
Expand Down Expand Up @@ -72,5 +91,5 @@ internal static bool HasPendingMigrations()

return result;
}
}
}
}
@@ -1,4 +1,8 @@
<Language Name="Deutsch" IsDefault="true" IsRightToLeft="false">
<LocaleResource Name="Plugins.FriendlyName.Widgets.DevToolsDemo" AppendRootKey="false">
<Value>Dev-Tools Demo Widget</Value>
</LocaleResource>

<LocaleResource Name="EnableMiniProfilerInPublicStore">
<Value>Mini-Profiler für Frontend aktivieren</Value>
</LocaleResource>
Expand Down
@@ -1,4 +1,8 @@
<Language Name="Deutsch" IsDefault="true" IsRightToLeft="false">
<LocaleResource Name="Plugins.FriendlyName.Widgets.DevToolsDemo" AppendRootKey="false">
<Value>Dev-Tools Demo Widget</Value>
</LocaleResource>

<LocaleResource Name="EnableMiniProfilerInPublicStore">
<Value>Enable Mini-Profiler in public store</Value>
</LocaleResource>
Expand Down

0 comments on commit 4066c68

Please sign in to comment.