开发者

How do you create a user creatable / editable content type in orchardproject.net cms

开发者 https://www.devze.com 2023-03-08 07:07 出处:网络
I\'m customizing an OrchardProject.net cms.I\'d like the users to be able to submit a \"deed\".It\'s a simple ContentType with a single text field.

I'm customizing an OrchardProject.net cms. I'd like the users to be able to submit a "deed". It's a simple ContentType with a single text field.

This is a piece of cake for a user with admin rights but I want a regular user 开发者_开发知识库without access to the admin panel to create it. Users can submit comments, but there are a lot of hoops to jump through to follow that model. (Record, part, controller, viewModel, views, etc..)

I would think the default system provides this but I can't figure out the route get it to generate it.


If you want to give a Role the ability to create and publish "Deed" content on your site, you can go into Roles (Dashboard -> Users -> Roles tab in Orchard 1.1) and give various permissions to a role (existing or new). Then, you would assign the role to a user.

After adding a Content Type called Deed (be sure to include the Common Part), the Roles tab allows the following permissions:

Publish or unpublish Deed for others
Publish or unpublish Deed
Edit Deed for others
Edit Deed
Delete Deed for others
Delete Deed

So, for example:

  1. Create a Role, DeedCreator with the two "Publish or unpublish..." permissions (in the Deed section
  2. You will also need to grant "Access admin panel" permissions in the Orchard.Framework section
  3. Create a user, User1 with DeedCreator role

Even though you granted Access admin panel permissions, the user will only be able to access the Create Deed page in the dashboard--nothing else.

If you want to allow Anonymous users (really, really, really not recommended), you could technically grant the aforementioned permissions to the Anonymous role. Keep in mind, Anonymous users would then have at least a surface-level angle of attack to your dashboard. Any user could navigate to www.yoursite.com/admin and start creating Deed content.

Update per comment

When I Saved my test Deed, here's what the POST to /Admin/Contents/Create/Deed looked like:

Body.Text:<p>test useraddable add (save)</p>
Deed.UserField1.Value:blah blah
CommentsActive:true
CommentsActive:false
CommonPart.Owner:admin
CommonPart.ContainerId:
submit.Save:submit.Save

Plus, there was a value for __RequestVerificationToken, which I'm not sure how to generate. (Maybe with the Html.BeginAntiForgeryPost helper in the Orchard.Mvc.Html namespace

0

精彩评论

暂无评论...
验证码 换一张
取 消