Creating Grouplets with PeopleCode
A grouplet is the encapsulation of content from one source (for example, a component, an iScript, or external content) that is presented within the context of another fluid application page. Tiles, embedded related content, and related information are all examples of grouplets. In each of these scenarios, the grouplets are created by the system at runtime based solely on configuration details.
However, you can use methods and properties of the Field class to generate grouplets from group box fields programmatically. The following example with comments illustrates how to create a grouplet based on component content. The behavior of the grouplet can be enhanced by optional method invocations to set a target URL, where the target content is displayed, and so on.
Example
Declare Function PSURLtoNewWin PeopleCode FUNCLIB_PTPP.PTPP_HYPERLINK FieldFormula;
Local string &src_URL = PSURLtoNewWin(GenerateComponentContentURL(%Portal, %Node, MenuName.MY_MENU, %Market, Component.COMPONENT_A, Page.MAIN_A, %Action_UpdateDisplay));
Local string &tgt_URL = PSURLtoNewWin(GenerateComponentContentURL(%Portal, %Node, MenuName.MY_MENU, %Market, Component.COMPONENT_B, Page.MAIN_A, %Action_UpdateDisplay));
Local Field &fld = GetField();
/* Use the following three methods to create a display-only grouplet. */
&fld.SetGroupletType(%GroupletNoStyle);
/* Specifies the grouplet's source content */
&fld.SetGroupletUrl(&src_URL);
/* Specifies the group box's page field name. Not used with interactive */
/* grouplets, which render the entire component. */
&fld.SetGroupletID("GRPLTC_NOINTER");
/* Optional. Specifies the target URL, which makes the entire grouplet tappable. */
&fld.SetGroupletActionUrl(&tgt_URL);
/* Optional. Specifies how the action URL is opened. Default is current window. */
&fld.SetGroupletDisplayIn(%GroupletActionInNewWindow); /* */
/* Enable the icon for zooming to open the modal – similar to related */
/* information in the right panel. */
<* &fld.IsGroupletZoomIconEnabled = True;
/* Modal options if %GroupletActionInModal is used for SetGroupletDisplayIn. */
&fld.SetGroupletMOptions("bAutoClose@0;"); *>
Related Topics
- PeopleCode API Reference: SetGroupletActionUrl method: Field class
- PeopleCode API Reference: SetGroupletDisplayIn method: Field class
- PeopleCode API Reference: SetGroupletEventMsg method: Field class
- PeopleCode API Reference: SetGroupletID method: Field class
- PeopleCode API Reference: SetGroupletImage method: Field class
- PeopleCode API Reference: SetGroupletImageUrl method: Field class
- PeopleCode API Reference: SetGroupletMOptions method: Field class
- PeopleCode API Reference: SetGroupletTargetID method: Field class
- PeopleCode API Reference: SetGroupletTimer method: Field class
- PeopleCode API Reference: SetGroupletType method: Field class
- PeopleCode API Reference: SetGroupletUrl method: Field class
- PeopleCode Language Reference: IsGroupletRequest function