Share your experiences with the ABP Framework!
ABP is an open source and community driven project. This guide is aims to help anyone wants to contribute to the project.
Share your experiences with the ABP Framework!
ABP is an open source and community driven project. This guide is aimed to help anyone who wants to contribute to the project.
If you want to write articles or "how to" guides related to the ABP Framework and ASP.NET Core, please submit your article to the community.abp.io web site.
Welcome Today Component
+@DateTime.Now.ToString()
+ +``` + +Now configuration time on YourModule.cs +```csharp +ConfigureWelcome Today Component
+@DateTime.Now.ToString(Format)
+ +``` + +Let's define the format component. +```csharp +[Widget] +[ViewComponent(Name = "Format")] +public class FormatViewComponent : AbpViewComponent +{ + public IViewComponentResult Invoke() + { + return View("~/ViewComponents/Format.cshtml", + new FormatViewModel()); + } +} + +public class FormatViewModel +{ + [DisplayName("Format your date in the component")] + public string Format { get; set; } +} +``` +> Important Note: To get properties properly you should set the `name` property on the razor page or you may use the ABP component. ABP handles that automatically. + +```html +@using Volo.CmsKit.ViewComponents +@model FormatViewModel + +Welcome Comment Date Component
-@if (Model.IsShow) -{ -@DateTime.Today.ToLongDateString()
-} -else -{ -Without date
-} \ No newline at end of file diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml deleted file mode 100644 index 0622000bb7..0000000000 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/DecisionCommentDate.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@using Volo.CmsKit.ViewComponents -@model DecisionCommentDateViewModel - -Welcome Today Component
+ +@DateTime.Now.ToString(Model.Format)
diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/TodayViewComponent.cs similarity index 50% rename from modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs rename to modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/TodayViewComponent.cs index 4122bb1481..f0be3ad33c 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/CommentDateViewComponent.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/ViewComponents/TodayViewComponent.cs @@ -9,17 +9,17 @@ namespace Volo.CmsKit.ViewComponents; AutoInitialize = true )] -[ViewComponent(Name = "CommentDate")] -public class CommentDateViewComponent : AbpViewComponent +[ViewComponent(Name = "CmsToday")] +public class TodayViewComponent : AbpViewComponent { - public bool IsShow { get; set; } + public string Format { get; set; } - public CommentDateViewComponent() + public TodayViewComponent() { } - public virtual async Task@L["PleaseConfigureWidgets"].Value
} - } - else - { -@L["PleaseConfigureWidgets"].Value
- }