OpenWGA 7.9 - OpenWGA Concepts and Features

Personalisation

Accessing the user profile

WebTML and TMLScript provide many ways to access the user profile in OpenWGA design.

One way to store data to the user profile is to use a WebTML form with attribute source set to "profile". The inputs defined inside the form will get stored as items to the profile when the default action $store is invoked on it.

<tml:form id="profiledata" source="profile">

  Your name: <tml:input name="name"/><br>

  Your date of birth: <tml:input name="birthdate" type="date"/><br>

  <tml:button clickaction="$save">Save</tml:button>

</tml:form>

Profile items can be retrieved using <tml:item type="profile"/>:

Welcome back, <tml:item name="name" type="profile"/> !

In TMLScript the object TMLUserProfile "this.profile" represents the profile of the current user and can be used to retrieve and store profile items:

profile.setItem("verified", true);


return profile.item("username");

Modifications done directly to the user profile in TMLScript are stored automatically at the end of the request.

Just like content documents a user profile also has metadata fields, offering some general data about it. See the Metadata of type="profile" for a reference of available fields. They can be retrieved using WebTML tag <tml:metadata type="profile"/> or TMLScript methods profile.meta() / profile.metaList().