Introduction:
Collection Provider can display collections represented by Object Entries. With the aid of Liferay Objects and Collection Provider, any actual entity, complete with all of its attributes, may be presented as content.For instance, an object is a real-world entity, such as an employee. The properties that an employee needs are an employee ID and name.The attributes of this entity can be described as the Object Fields, and it can be stored as a Liferay object.Without creating any code, we may display it as some content on a page by using an asset publisher template.Prerequisites:
- Liferay DXP/Portal 7.4+
Liferay Objects
One of the most potent features offered by Liferay 7.4 is Liferay Objects. Data can be stored and processed using Liferay objects. With Liferay Objects, applications can be created without writing any code.Collection Provider
Collection providers organize items into groups so that they can be used for display purposes. Liferay provides several collections of OOTB or they can be created using Information Framework.Creating Object Entries for Collections
- Create a Site-level object and add a few object fields.
![Object with site scope | Rendering Data using Liferay Object and Collection Provider Object with site scope](https://www.ignek.com/wp-content/uploads/2024/05/Object-with-site-scope.webp)
- Insert a few sample entries inside the object.
![Object Entries in Site Scoped objects | Rendering Data using Liferay Object and Collection Provider Object Entries in Site Scoped objects](https://www.ignek.com/wp-content/uploads/2024/05/Object-Entries-in-Site-Scoped-objects.webp)
Publishing and Collection Provider
- On a page, add a Collection Display
![Collection from Fragments and Widgets | Rendering Data using Liferay Object and Collection Provider Collection from Fragments and Widgets](https://www.ignek.com/wp-content/uploads/2024/05/Collection-from-Fragments-and-Widgets-1024x500.webp)
- Click on the (+) icon to select the collection.
![icon in Collection | Rendering Data using Liferay Object and Collection Provider icon in Collection](https://www.ignek.com/wp-content/uploads/2024/05/icon-in-Collection-1024x492.webp)
- From the collection provider tab, select the collection.
![Select Collection | Rendering Data using Liferay Object and Collection Provider Select Collection](https://www.ignek.com/wp-content/uploads/2024/05/Select-Collection.webp)
- The object entries of the collection are visible now.
![Collection displayed | Rendering Data using Liferay Object and Collection Provider Collection displayed](https://www.ignek.com/wp-content/uploads/2024/05/Collection-displayed-1024x351.webp)
- Select ‘card’ from the fragments, and deploy it over the collection provider. Using this, the layout of the collection provider can be changed.
![Card type selected | Rendering Data using Liferay Object and Collection Provider Card type selected](https://www.ignek.com/wp-content/uploads/2024/05/Card-type-selected-1024x462.webp)
- Double-clicking on the text can map the text value to the collection’s value.
![Changing title of Card | Rendering Data using Liferay Object and Collection Provider Changing title of Card](https://www.ignek.com/wp-content/uploads/2024/05/Changing-title-of-Card-1024x500.webp)
- Style display can also be changed.
![Displaying collection | Rendering Data using Liferay Object and Collection Provider Collection](https://www.ignek.com/wp-content/uploads/2024/05/Displaying-collection.webp)
- Likewise, the look and feel of the page can be altered by adding different elements and styles.
Explore our Liferay Development & Customization services to learn more about how we can help you succeed. Whether you’re a small startup, SME, or large enterprise, we have the expertise and resources to support your requirements and goals. Check out our “Hire Us” services to get started.