From 157c9dc80a621f4ea95f4f654afeb9d7d74a7c3d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 9 Jun 2023 15:21:30 +0800 Subject: [PATCH 1/3] Add "Entity Extensions" section to CMS Kit documentation --- docs/en/Modules/Cms-Kit/Index.md | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/docs/en/Modules/Cms-Kit/Index.md b/docs/en/Modules/Cms-Kit/Index.md index e40f78922e..6726a528b1 100644 --- a/docs/en/Modules/Cms-Kit/Index.md +++ b/docs/en/Modules/Cms-Kit/Index.md @@ -80,3 +80,66 @@ All tables/collections use the `Cms` prefix by default. Set static properties on This module uses `CmsKit` for the connection string name. If you don't define a connection string with this name, it fallbacks to the `Default` connection string. See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. + +## Entity Extensions + +[Module entity extension](https://docs.abp.io/en/abp/latest/Module-Entity-Extensions) system is a **high-level** extension system that allows you to **define new properties** for existing entities of the dependent modules. It automatically **adds properties to the entity**, **database**, **HTTP API and user interface** in a single point. + +To extend entities of the CMS Kit Pro module, open your `YourProjectNameModuleExtensionConfigurator` class inside of your `DomainShared` project and change the `ConfigureExtraProperties` method like shown below. + +```csharp +public static void ConfigureExtraProperties() +{ + OneTimeRunner.Run(() => + { + ObjectExtensionManager.Instance.Modules() + .ConfigureCmsKit(cmsKit => + { + cmsKit.ConfigureBlog(plan => // extend the Blog entity + { + plan.AddOrUpdateProperty( //property type: string + "BlogDescription", //property name + property => { + //validation rules + property.Attributes.Add(new RequiredAttribute()); //adds required attribute to the defined property + + //...other configurations for this property + } + ); + }); + + cmsKit.ConfigureBlogPost(blogPost => // extend the BlogPost entity + { + blogPost.AddOrUpdateProperty( //property type: string + "BlogPostDescription", //property name + property => { + //validation rules + property.Attributes.Add(new RequiredAttribute()); //adds required attribute to the defined property + property.Attributes.Add( + new StringLengthAttribute(MyConsts.MaximumDescriptionLength) { + MinimumLength = MyConsts.MinimumDescriptionLength + } + ); + + //...other configurations for this property + } + ); + }); + }); + }); +} +``` + +* `ConfigureCmsKit(...)` method is used to configure the entities of the CMS Kit module. + +* `cmsKit.ConfigureBlog(...)` is used to configure the **Blog** entity of the CMS Kit module. You can add or update your extra properties of the +**Blog** entity. + +* `cmsKit.ConfigureBlogPost(...)` is used to configure the **BlogPost** entity of the CMS Kit module. You can add or update your extra properties of the **BlogPost** entity. + +* You can also set some validation rules for the property that you defined. In the above sample, `RequiredAttribute` and `StringLengthAttribute` were added for the property named **"NewsletterRecord"**. + +* When you define the new property, it will automatically add to **Entity**, **HTTP API** and **UI** for you. + * Once you define a property, it appears in the create and update forms of the related entity. + * New properties also appear in the datatable of the related page. + From 45bc4f0190b04abce4dc4b40f8741cc8bed86d89 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:55:59 +0300 Subject: [PATCH 2/3] Update Blogging.md --- docs/en/Modules/Cms-Kit/Blogging.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/en/Modules/Cms-Kit/Blogging.md b/docs/en/Modules/Cms-Kit/Blogging.md index 91c14d79e8..d45598be52 100644 --- a/docs/en/Modules/Cms-Kit/Blogging.md +++ b/docs/en/Modules/Cms-Kit/Blogging.md @@ -118,4 +118,8 @@ This module follows the [Domain Services Best Practices & Conventions](https://d - CmsBlogs - CmsBlogPosts -- CmsBlogFeatures \ No newline at end of file +- CmsBlogFeatures + +## Entity Extensions + +Check the ["Entity Extensions" section of the CMS Kit Module documentation](Index.md#entity-extensions) to see how to extend entities of the Blogging Feature of the CMS Kit module. \ No newline at end of file From 3f81ac7a2d8732edc0e55d6894ae61c0660ef40b Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Fri, 9 Jun 2023 10:57:16 +0300 Subject: [PATCH 3/3] Update docs/en/Modules/Cms-Kit/Index.md Co-authored-by: Qingxiao Ren --- docs/en/Modules/Cms-Kit/Index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/Modules/Cms-Kit/Index.md b/docs/en/Modules/Cms-Kit/Index.md index 6726a528b1..952fa87aba 100644 --- a/docs/en/Modules/Cms-Kit/Index.md +++ b/docs/en/Modules/Cms-Kit/Index.md @@ -137,7 +137,7 @@ public static void ConfigureExtraProperties() * `cmsKit.ConfigureBlogPost(...)` is used to configure the **BlogPost** entity of the CMS Kit module. You can add or update your extra properties of the **BlogPost** entity. -* You can also set some validation rules for the property that you defined. In the above sample, `RequiredAttribute` and `StringLengthAttribute` were added for the property named **"NewsletterRecord"**. +* You can also set some validation rules for the property that you defined. In the above sample, `RequiredAttribute` and `StringLengthAttribute` were added for the property named **"BlogPostDescription"**. * When you define the new property, it will automatically add to **Entity**, **HTTP API** and **UI** for you. * Once you define a property, it appears in the create and update forms of the related entity.