Discussion render editor in frontend

Topics: Core, General, Writing modules
Jul 14, 2012 at 11:29 AM

In many modules i see often that the backend editor for the custom part is rendered in the frontend. Is there an other reason to do this except for that it's easy and fast to create? The only reason i can think of is that you don't have to create a custom controller and action for this editor.

This way of creating a frontend form seems to me a little bit odd and unsafe. Unsafe because when you add an backend property which is only for backend you can easily forget to hide this item from the frontend. That's why i think it would be a very nice addition if we can enhance the driver to make this possible like sfmskywalker explained in: http://orchard.codeplex.com/discussions/279425

What do you guys think about this?

Jul 14, 2012 at 1:41 PM

I happen to know such a module that specifically handles discussions ;-).

If you want your content types to be extensible and manageable just as they should be, then the only option for you to have an editor for them is to use ContentManager.BuildEditor() in the frontend. There is nothing odd with this for me. Of course you should be careful what content types' editors make you available this way, and for fine-tuning you could need part-level permissions too (so e.g. normal users can't see a part's editor, just admins).

What Sipke talks about is I think a different matter and wouldn't change the current state that if you want editors, you have to build editors. Actually I think (but haven't tried yet, will shortly) doing a proper postback-editor refresh is possible (although not very nicely for my taste) with TempData like I've described here in the last post, however it still needs a custom controller.

Jul 14, 2012 at 3:33 PM

ok fair enough but is it possible to submit data to a part of a rendered editor in the frontend which is made hidden by placement?Or is that hidden part excluded when you call the UpdateEditor method?

Jul 14, 2012 at 5:34 PM

If the question is whether a part's editor that's shape(s) is (are) hidden gets called (the POST one), then I think it will, but I haven't really tried it, why don't you take a look? :-) Such partial postback doesn't exist in my knowledge. If you want such, maybe your best bet is to use AJAX in your part's shapes and post to some custom controller (e.g. your part displays a button that should do something, then make it simply call a custom action).

But what do you really want to achieve?

Jul 14, 2012 at 8:22 PM
Edited Jul 14, 2012 at 8:22 PM

Oh no i don't want to achieve something with it, but i was wondering if hidden editors parts and fields are still accessible to post while they are not visible. Because this could result in security issues when you are not realizing this.

I'm using for instance an custom edited ShoutBox module and it's rendering the backend editor in the frontend. I have hidden the CommonPart in the frontend and I'm wondering if it's possible to change the contents of the commonpart by a custom post, even though it's not visible to the users.

Jul 15, 2012 at 9:12 AM

I also worked on that module as well, unless there are multiple shoutbox modules :-). I tried it out and even if the date or owner editors of CommonPart are shown I can't edit either of them... What is strange.