Example: Editing partner profile

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

In this example, you will create a list of partners who will be able to edit their profile on the My profile page after they have signed in. This example assumes that you are using the Corporate Site sample website.

 

Create the partner document type
Create the partner list
Create the partner user account
Create the partner profile document
Create the partner profile editing page
Test the profile editing page

 

Creating the partner document type

 

 

 

Please note

 

A detailed description of how to create a new document type can be found in the Document types and transformations -> Defining a new document type topic in the Development section of the Developer's Guide.

 

 

Before you create the page, it is necessary that you create a new document type Partner. Sign in to Site Manager and go to Development -> Document types where you need to click the AddNewDocumentType New document type link.

 

devguide_clip1344

 

Step 1: General

 

Enter the following values and click the Next button.

 

Document type display name: Partner (this name will be displayed to the users)
Document type code name: custom.Partner

 

devguide_clip1345

 

Please note that custom in the Document type code name field is your namespace to distinguish your document types from system types that use the cms namespace. You will use this value in web part properties later.

 

Step 2: Data type

 

You need to choose the name of the database table that will be used for storing partner details. You also need to enter the name of the primary key in this table. Choose the option The document type has custom fields and enter the following values:

 

Table name: custom_Partner
Primary key name: PartnerID

 

devguide_clip1346

 

Click Next.

 

Step 3: Fields

 

Now you need to define the columns of the table or fields. Click New attribute (AddWebPart) to create a new field, enter the following values and click OK.

 

Attribute name: PartnerName
Attribute type: Text
Attribute size: 100
Field caption: Partner name
Field type: TextBox

 

Attribute name: PartnerProfile
Attribute type: Long Text
Field caption: Partner profile
Field type: HTML area (Formatted Text)

 

When you have defined both the fields, click Next again.

 

devguide_clip1347

 

Step 4: Additional Settings

 

Now you need to choose the field that will be used as document name. Choose the PartnerName field option from the Document name source drop-down list and click Next.

 

Document name source: PartnerName

 

devguide_clip1348

 

Step 5: Parent types

 

In this step, you need to select the document types under which the partner documents will be displayed. Check only the Page (menu item) value, which means the users will be able to create computer documents only under some page, not under article or news document in the content tree. Click the Next button.

 

devguide_clip1349

 

Step 6: Sites

 

Here you need to choose which websites will use this document type. Choose your current website and click Next.

 

devguide_clip1350

 

Step 7: Search options

 

In this step, you are asked to specify how documents of this type will be indexed and displayed in the search results. For more information on these settings, please refer to the Settings for particular object types topic. Make your choice and click Next.

 

devguide_clip1351

Step 8: The wizard has finished

 

Step 8 is the last step in the process of creating the partner document type - the wizard has finished the configuration of the this document type.

 

devguide_clip1352

 

Creating the partner list

 

1. Go to CMS Desk -> Content, choose Examples from the content tree, click NewDocument New and choose to create a new CMS_MenuItem Page (menu item) document. Call the page Partner directory and choose the Create a blank page option. Select the Simple layout and click Save Save.

 

devguide_clip0744

 

2. Switch to the Design tab of the newly created page and add the Listings and viewers/Repeater web part. Set the following properties:

 

ID: repeaterPartners
Document types: custom.partner
Transformation: custom.Partner.Default
Selected item transformation: custom.Partner.Default

 

devguide_clip1353

 

Please note that the default transformation generated by the system will be used. You can later modify the transformation so that it meets your design and layout requirements.

 

3. Click OK. Switch to the Page view and you will see an empty page now.

 

Creating the partner user account

 

1. Go to CMS Desk -> Administration -> Users and by clicking the AddNewUser New user link create a new user with user name AAAWebDesign. Set the Is editor property to no (unchecked) and assign the user to the CMS Basic users role.

 

devguide_clip1354

 

2. For the purpose of this example, choose no (uncheck the box) in the Is editor field - AAA Web Design is a common site member without access to Kentico CMS Desk. Click OK to save the changes.

 

devguide_clip1355

 

Creating the partner profile document

 

1. Go to CMS Desk -> Content, from the content tree, choose /Examples/Partner directory and click NewDocument New. Choose to create a new Partner and enter the following values:

 

Partner name: AAA Web Design Inc.
Partner profile: We provide web development services.

 

devguide_clip1356

 

2. Click Save Save. Go to the Properties -> URLs tab of the newly created document, set the Document alias to AAAWebDesign and click Save Save. You need to use the same alias as the user name since you will be using them to match the users to their user profiles. The alias path of the document will always be /Examples/Partner-directory/<user name>.

 

devguide_clip1358

 

3. When you display the page in the Live site mode now, you will see a page like this:

 

devguide_clip0747

 

Creating the partner profile editing page

 

Now you will create a page that will be available only to partners and that will allow them to edit their partner profile.

 

1. Go to CMS Desk -> Content, from the content tree, choose /Examples and click NewDocument New. Choose to create a new CMS_MenuItem Page (menu item). Call the page My profile and choose the Create a blank page option. Choose the Simple layout and click Save Save.

 

2. Switch to the Design tab of the newly created page and add the Listings and viewers/Repeater web part. It will display the current user's partner profile. Enter the following values and click OK.

 

ID: repeaterPartners
Path: /Examples/Partner-directory/{%UserName%}
- this ensures that the page displays the profile that matches the current user. The {%UserName%} macro is resolved as the user name of the current site visitor.
Document types: custom.partner
Transformation: custom.Partner.Default
Selected item transformation: custom.Partner.Default
Hide if no record found: no (unchecked)
No record found text: No partner profile was found for your user account.
Content before: <h1>Your Partner Profile</h1>

 

devguide_clip1360

 

3. Add the User contributions/Edit contribution web part, enter the following values and click OK.

 

Path: /Examples/Partner-directory/{%UserName%}
- this ensures that the form edits the profile that matches the current user. The {%UserName%} macro is resolved as the user name of the current site visitor.
Allow delete: no (unchecked)
- this option hides the Delete button since you do not want the partners to delete their profile accidentally.
Allow editing by users: Authenticated
- you want to allow editing only to authenticated users; at the same time, you do not require the user to be a document owner.

 

Please note that the Edit contribution web part is missing the Allow insert/edit properties.

 

devguide_clip1361

 

4. As the last step, go to the Properties -> Security dialog, set the Requires authentication value to Yes and click OK - the reason is that you want to allow access to this page only to authenticated partners so that you know their user name and can display their profile.

 

devguide_clip1362

 

Testing the profile editing page

 

1. Sign out and go to Examples -> My profile. You will be displayed with logon form.

 

devguide_clip1366

 

2. Sign in as user AAAWebDesign and you will see your partner profile with the Edit Edit link.

 

devguide_clip0756

3. Click Edit Edit to open the edit dialog window, modify some values and click Save Save.

 

devguide_clip0757

 

4. Go to Examples -> Partner directory and you will see the updated profile.

 

devguide_clip0758

 

In this topic, you have learnt how to allow users (partners) to edit a single document that matches their user name. It was a little different in comparison to the previous example (Example: Publishing community news), since in this case, you created the document first and only then you mapped it to the user by matching the document alias path and user name. In this example, the partner was not allowed to create new documents and you did not use the document owner security option.

 

 

 

Hint 1: Simplifying the process of creating a new partner

 

In such cases, it is useful to create a custom module (see Custom modules) that will contain a custom form for creating new partners. Your code will ensure creating the user, the default partner profile and setting the document alias path and user name to the same value. You will need to use Kentico CMS to create the user account (see Managing users) and the partner profile document (see Create document).

 

Hint 2: Assigning multiple users to the same partner profile

 

If the user name/document alias path mapping does not fit your needs or if you need to assign multiple users to the same partner profile, you can use another option: Go to Site Manager -> Development -> System tables -> User and create a custom text field PartnerProfileAliasPath. You will use this custom field in the user profile to specify the partner profile that can be edited by the given user. Then, the Path property in the Edit contribution web part will be set to value {%PartnerProfileAliasPath%}. Please note that you will find your new custom field on the Custom Fields tab, not on the General tab as the default attributes.

 

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?example_editing_partner_profile.htm