oo

Displaying Object Entries with Collection Providers

Liferay 7.4 U77+/GA77+

When you publish an object definition, Liferay creates a collection provider for it. You can use this provider with the Collection Display fragment and collection pages to display its entries. Objects support all collection display features, including filtering, styling, and display options.

Using an Object’s Collection Provider

  1. Create a new content page or display page template. Alternatively, begin editing ( Edit Button ) an existing one.

    note

    You can also create a collection page using the collection provider. See Collections and Collection Pages for more information.

  2. Drag and drop the Collection Display fragment into the page or template from the Fragments and Widgets (Fragments and Widgets) sidebar.

  3. Select the Collection Display Fragment to access its configuration options and click Select Collection in the General tab.

    Select the fragment and click Select Collection.

  4. In the modal window, click the Collection Providers tab and select the object’s provider.

    In the Collection Providers tab, select the object's provider.

  5. (Optional) Filter the displayed object entries. You can filter by any picklist or boolean fields in the object:

    Click Collection Options (Collection Options Button) and select Filter Collection.

    Click the Collection Options button and select Filter Collection.

    Then select the desired filters and click Apply.

    Select the Filters to apply.

After selecting the desired provider, use additional fragment options to determine how Object entries appear, including List Style and Pagination.

Mapping Fragments to Object Fields

When you select an object for a Collection Display fragment, the object is set as its mapping source. Now you can add fragments to it and map their sub-elements to object fields to create flexible page displays for individual object entries. This is true for collection pages as well.

For example, you can embed a button in a Collection Display fragment mapped to an object and then configure the button’s link to display the name of each item in the collection.

Map fragment sub-elements in Collection Display fragments to object fields.

important

Mapping fragment elements to related object fields is behind a release feature flag. Read Release Feature Flags for more information.

If the mapped object is on the child side of a one-to-many relationship, you can map fragment elements to fields in the parent object. The embedded Collection Display fragment uses a unique related items collection provider to form the new collection.

For example, if a City object (child) is related to a Country object (parent), you can map fragments to fields in the Country object.

To map fragments to a related object’s fields,

  1. Use the Object’s collection provider with a Collection Display fragment.

  2. Embed another Collection Display fragment within the initial Collection Display.

    tip

    Using the Browser tab in the page edit menu can help you position the fragment more precisely within the page hierarchy.

    Use the Browser tab to help properly embed the Collection Display fragment.

  3. Click Select Collection in the new Collection Display fragment’s configuration options.

  4. Click the Related Items Collection Providers tab.

  5. Select the collection provider with the name of the object’s relationship. The associated object type appears under the relationship’s name. In this example, the relationship is called cities in country:

    Select the relationship that you created with between the displayed object and another object type.

Now you can embed fragments in the new Collection Display and map them to fields in the related object.

Map fragment sub-elements to fields in parent objects.

Feature: