Browse Source

created the first dynamic poll

pull/13082/head
malik masis 4 years ago
parent
commit
a2d9f457fc
  1. 11
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs
  2. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml

11
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs

@ -28,6 +28,9 @@ public class ContentParser : IContentParser, ITransientDependency
MatchCollection mc = Regex.Matches(content, @"(?<=\[Wid)(.*?)(?=\])");//(?<=X)(.*?)(?=Y) MatchCollection mc = Regex.Matches(content, @"(?<=\[Wid)(.*?)(?=\])");//(?<=X)(.*?)(?=Y)
MatchCollection mcPollName = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")");
var pollNames = mcPollName.Select(p => p.Value).ToList();
string split = "-----"; string split = "-----";
var polls = new List<string>(); var polls = new List<string>();
@ -41,16 +44,16 @@ public class ContentParser : IContentParser, ITransientDependency
var contentFragments = new List<ContentFragment>(); var contentFragments = new List<ContentFragment>();
var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name; var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name;
for (int b = 0; b < splittedContent.Length; b++) for (int i = 0; i < splittedContent.Length; i++)
{ {
contentFragments.Add(new MarkdownContentFragment() { Content = splittedContent[b] }); contentFragments.Add(new MarkdownContentFragment() { Content = splittedContent[i] });
if (b != splittedContent.Length - 1) if (i != splittedContent.Length - 1)
{ {
contentFragments.Add(new WidgetContentFragment(name) contentFragments.Add(new WidgetContentFragment(name)
{ {
Properties = Properties =
{ {
{ "name", "poll-name" } { "name", pollNames[i] }
} }
}); });
} }

2
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml

@ -20,7 +20,7 @@
{ {
@await Component.InvokeAsync(widgetContentFragment.Name, new @await Component.InvokeAsync(widgetContentFragment.Name, new
{ {
name = "poll-name" name = widgetContentFragment.Properties.FirstOrDefault().Value
}) })
} }
} }

Loading…
Cancel
Save