Skip to content

Commit 696e40d

Browse files
committed
Fixed topic widgets rendering with activated OutputCache
1 parent c6073c3 commit 696e40d

4 files changed

Lines changed: 25 additions & 20 deletions

File tree

src/Libraries/SmartStore.Core/Caching/OutputCache/DisplayControl.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,7 @@ public virtual IEnumerable<string> GetCacheControlTagsFor(BaseEntity entity)
236236
}
237237
else if (type == typeof(Topic))
238238
{
239-
var topic = ((Topic)entity);
240-
if (!topic.RenderAsWidget)
241-
{
242-
yield return "t" + topic.Id;
243-
}
239+
yield return "t" + entity.Id;
244240
}
245241
}
246242

src/Presentation/SmartStore.Web/Infrastructure/DefaultWidgetSelector.cs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using SmartStore.Web.Framework.UI;
1616
using SmartStore.Web.Infrastructure.Cache;
1717
using SmartStore.Web.Models.Topics;
18+
using SmartStore.Core.Domain.Topics;
1819

1920
namespace SmartStore.Web.Infrastructure
2021
{
@@ -145,6 +146,7 @@ public virtual IEnumerable<WidgetRouteInfo> GetWidgets(string widgetZone, object
145146
} }
146147
}
147148
};
149+
148150
map.Add(zone, routeInfo);
149151
}
150152
}
@@ -186,6 +188,13 @@ public virtual IEnumerable<WidgetRouteInfo> GetWidgets(string widgetZone, object
186188
var zoneWidgets = topicsByZone[widgetZone.ToLower()];
187189
foreach (var topicWidget in zoneWidgets)
188190
{
191+
// Handle OC announcement
192+
var topicWidgetModel = topicWidget.RouteValues["model"] as TopicWidgetModel;
193+
if (topicWidgetModel != null)
194+
{
195+
_services.DisplayControl.Announce(new Topic { Id = topicWidgetModel.Id });
196+
}
197+
189198
yield return topicWidget;
190199
}
191200
}
@@ -206,21 +215,19 @@ public virtual IEnumerable<WidgetRouteInfo> GetWidgets(string widgetZone, object
206215

207216
#endregion
208217
}
209-
210-
class TopicWidgetStub
211-
{
212-
public int Id { get; set; }
213-
public string[] WidgetZones { get; set; }
214-
public string SystemName { get; set; }
215-
public bool WrapContent { get; set; }
216-
public bool ShowTitle { get; set; }
217-
public bool Bordered { get; set; }
218-
public string Title { get; set; }
219-
public string TitleTag { get; set; }
220-
public string Body { get; set; }
221-
public int Priority { get; set; }
222-
}
223-
224218
}
225219

220+
public class TopicWidgetStub
221+
{
222+
public int Id { get; set; }
223+
public string[] WidgetZones { get; set; }
224+
public string SystemName { get; set; }
225+
public bool WrapContent { get; set; }
226+
public bool ShowTitle { get; set; }
227+
public bool Bordered { get; set; }
228+
public string Title { get; set; }
229+
public string TitleTag { get; set; }
230+
public string Body { get; set; }
231+
public int Priority { get; set; }
232+
}
226233
}

src/Presentation/SmartStore.Web/Views/Topic/Partials/TopicWidget.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@model TopicWidgetModel
2+
23
@using SmartStore.Web.Models.Topics;
34

45
@{

src/Presentation/SmartStore.Web/Views/Widget/Partials/WidgetsByZone.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@model WidgetZoneModel
2+
23
@using SmartStore.Web.Framework.UI;
34

45
@foreach (var widget in Model.Widgets) {

0 commit comments

Comments
 (0)