Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Custom forms for Documents, Custom Tables, and User profiles. View modes: 
User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 1/27/2012 10:46:06 AM
   
Custom forms for Documents, Custom Tables, and User profiles.
I am working on a site that will have many forms where Authenticated users will need to be able to create documents that will need to be automatically placed in the document tree where appropriate for that user. The forms obviously need to be on a page and not in the CMSDesk.

I know that I can create custom form layouts using the Alternative forms, but I need some custom post-processing and possibly some custom form controls. Is there a standard way of doing this?

I assume that I will need to write a custom form, which I am fine with, but I would like to know if there is some way that I can add the document type's form field controls as they are configured in the document type management section. If so, how do I go about doing this?

I also want to make sure that I don't miss any important processing that may be going on in the CMS forms other than just saving the fields to the database. How can I make sure that this happens when writing a custom form?

I would like to also do this for Custom Tables and User Profiles, so please let me know if these are done the same way or not.

I appreciate any help with this.

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 1/28/2012 8:02:09 PM
   
RE:Custom forms for Documents, Custom Tables, and User profiles.
Hi,

The easiest way would be to use user contribution web parts which can be used on live site as described here:

http://devnet.kentico.com/docs/devguide/user_contributions_overview.htm

You can create alternative form for your document type which will be then used in user contribution web part. You can even develop custom control if you do not find the built-in ones sufficient for your needs:

http://devnet.kentico.com/docs/devguide/developing_form_controls.htm

If you would like to perform some post-processing after or even before the document is inserted/updated, you can do so with global event (document) handlers as described here:

http://devnet.kentico.com/docs/devguide/event_handlers_overview.htm

If you would like to go the way were completely custom form will be used, please bear in mind that we are talking about documents which are not used only in one table. They are stored in several tables:

CMS_Tree
CMS_Document
CustomDocumentTypeTabl
e

You can use our API to create/update documents as described with examples here:

http://devnet.kentico.com/docs/devguide/documents_api_examples_creating_documents.htm

If you are interested how form engine in Kentico CMS works, please take a look on this video where I’m explaining the concept:

http://devnet.kentico.com/Videos/API/Kentico-CMS-Form-Engine.aspx

Thanks,
Miro

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 1/30/2012 9:05:44 AM
   
RE:Custom forms for Documents, Custom Tables, and User profiles.
Thanks for that very informative reply. I will likely need to go the route of creating a fully custom form. What I really would like to know is if there are any existing methods in Kentico that would allow me to easily instantiate the form controls for a field of a document type so that I can add them to a form more easily. I mean something like what must be going on behind the scenes to replace the $$input:fieldname$$ macros in an Alternative Form layout. Can I do something like this?

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 2/1/2012 10:12:13 AM
   
RE:Custom forms for Documents, Custom Tables, and User profiles.
I really like these new global event handlers, they are pretty useful.

I only wish that I could somehow gain reference to the form that was used to save the document (WHEN a form is used).

For the most part though, I have enough information in the event args and cmscontext to do what I need. Thanks for the great resource!

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 2/18/2012 9:01:38 PM
   
RE:Custom forms for Documents, Custom Tables, and User profiles.
Hi,

Is there any particular reason why you would need to have reference to the FORM which initialized saving of the document/object in general?

I just want to understand that what you are looking to do. I’m missing the context of your question here.

Also, there is no straightforward method which you would call to resolve your form controls based on its name or so. Form engine is really complex engine. So, if you would provide me with some detail explanation what you are trying to achieve (what is your ultimate goal) then I can point you in the right direction.

Thanks,
Miro

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 2/21/2012 11:25:18 AM
   
RE:Custom forms for Documents, Custom Tables, and User profiles.
I was able to do what I wanted by creating a custom form control. It was quite difficult to do what I wanted, but I managed to get it to work.

I made it so that when a user uploads a business profile photo, it automatically creates a cropped square thumbnail and stores the attachmentguid in another field. It also allows them to edit the positioning of the square for the thumbnail from the original image any time they want. It works much like Facebook's profile photos works. This was much more difficult to do than I would have liked. There are not enough events to subscribe to in the saving process and the silverlight upload control needs to expose events so that we can do things after the file is uploaded.

The next challenge is to somehow do this for User Avatars. I don't yet see a way to do this since the UserAvatar field is very special and I cannot store files in the user settings table. I want to have a square avatar thumbnail that the system can automatically cache and create additional thumbnail sizes when they are requested. This, unfortunately, looks as though it is going to be a difficult undertaking because Kentico doesn't really facilitate what I want to do very well.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/6/2012 5:46:11 AM
   
RE:Custom forms for Documents, Custom Tables, and User profiles.
Hi,

in the CMS_UserSettings web part is stored only ID of avatar. The data are stored in the CMS_Avatar table.

It means you can use your form control in the User - Settings system table (add a new field to this table) and store only GUID in the CMS_UserSettings web part.

As for references. I still do not understand why you need to know the reference. If you used multiple forms (user contribution web parts), each one was probably used for creating a different document. Each document in Kentico has a unique classname, for example cms.news. Using this class name you could differentiate between documents.

Best regards,
Ivana Tomanickova