abp
abp copied to clipboard
Use of CMS kit in Own module
I want to use the cmskit commenting subsystem in a issue tracking module which I have developed but the documentation is not clear on how to use the commenting system ….. my module will be dependant on cmskit do I meet to include the nugget package of cmskit in my module ??
In order to use the Comment Sub System I have referenced the Volo.Cmskit.Common.Application
in my Amazing.Software.IssueTracking.Application
and added the following to my IssueTrackingApplicationModule
is my approach right ?
Hi @vnetonline
Common packages include only common logic between CmsKit.Admin
and CmsKit.Public
packages and mostly don't include business logic inside it.
If you want to use comments in your public website (users can comment some contents in your application),
you can use CmsKit.Public
packages.
- Install
CmsKit.Public.*
packages to your each layer. - You should enable it
GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => { cmsKit.Comments.Enable(); });
You can follow this documentation for installing & enabling CmsKit
- You should create a new migration and apply it before starting to use CmsKit.
-
After successfully completing installing & enabling processes, you should mark an entity name as commendable, let say it's
Product
Configure<CmsKitCommentOptions>(options => { options.EntityTypes.Add(new CommentEntityTypeDefinition("Product")); });
-
Then you can place anywhere a commenting section like that:
@await Component.InvokeAsync(typeof(CommentingViewComponent), new { entityType = "Product", entityId = "123" })
Please follow CmsKit: Comments documentation for advanced usage scenarios
my question is how i use it in my module
Your module can still depend on the CMS Kit packages like a regular application.
In order to use the Comment Sub System I have referenced the
Volo.Cmskit.Common.Application
in myAmazing.Software.IssueTracking.Application
...
In that image I see Volo.CmsKit.Common.Application
package, that's why I'm suggesting installing Admin or Public packages of Cms Kit.
If you want to add a new comment from code, you should use Volo.CmsKit.Public
packages and you can use AppServices of CmsKit like this:
public class YourAppService : ApplicationService
{
public ICommentPublicAppService CommentPublicAppService { get; }
public YourAppService(ICommentPublicAppService commentPublicAppService)
{
CommentPublicAppService = commentPublicAppService
}
public async Task DoSomethingAsync(SomeDto dto)
{
// ...
var comment = await CommentPublicAppService.CreateAsync("MyEntity", dto.Id, new CreateCommentInput
{
Text = "Hello World!"
});
// do something with comment.
}
}
...
is my approach right ?
As an answer for that, I strongly suggest to you, depending your project on CmsKit Public packages instead of Common packages. And rest of your approach seems right 👍
@enisn
I think the documentation is wrong then
the document states to put the Definitions in the *.Domain
or *.Domain.Shared
project but the domain projects don't reference the *.Application.Contracts
module so you can't create, update and delete policies.
You have to add a complete reference to your projects like below:
This is a basic dependency scheme
- Volo.Abp.CmsKit.Domain -> YourProjectName.Domain
- Volo.Abp.CmsKit.Domain.Shared -> YourProjectName.Domain.Shared
- Volo.Abp.CmsKit.MongoDB -> YourProjectName.MongoDB
- Volo.Abp.CmsKit.EntityFrameworkCore -> YourProjectName.EntityFrameworkCore
- Volo.CmsKit.HttpApi.Client -> YourProjectName.HttpApi.Client
- Volo.CmsKit.HttpApi -> YourProjectName.HttpApi
- Volo.CmsKit.Public.Application -> YourProjectName.Application
- Volo.CmsKit.Public.Application.Contracts -> YourProjectName.Application.Contracts
- Volo.CmsKit.Web -> YourProjectName.Web
Each layer should depend on the same layer of CmsKit.
I mentioned before, If you don't need Admin related codes, you can just add only Volo.CmsKit.Public.* package references.
Thanks for your reply @enisn I get what you are suggesting, however, if add Volo.Abp.CmsKit.EntityFrameworkCore -> YourProjectName.EntityFrameworkCore reference to my module ... will my module also install the migrations for CmsKit?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.