Asset Publisher

Expert Insights Hub

Stay connected with us to discover what top tech minds think about cutting-edge trends, development platforms, team hiring, automation, and innovations shaping the industry. Gain valuable knowledge from industry leaders, explore unique strategies, and stay ahead in the ever-evolving world of technology. Stay informed, stay inspired, and stay ahead of the competition with our exclusive updates!

Blogs

Create Liferay Objects Using Asset Library and Account

Overview: 

In Liferay, creating custom Liferay Objects and utilizing Asset Libraries alongside Accounts offers an effective solution for managing both content and organizational data. You can use Asset Libraries to manage and organize digital content such as images, documents, and videos, making content management more streamlined. By associating custom Liferay Objects with Accounts, you establish a relationship between your business data and specific organizations or business units. 

This integration enables you to display the connection between custom objects and the Account system object, creating a seamless experience for organizing and managing both content and data. By leveraging this relationship, you can efficiently handle assets and custom data linked to specific accounts, improving content management and enhancing data organization within the Liferay platform. 

Prerequisite: 

  • JDK 11 
  • Liferay Server: liferay-dxp-tomcat-7.4.13.u92 
  • Liferay Developer Studio:  3.9.7.202207131011-ga8 

Liferay Objects:

  • Liferay Objects are custom data entities that can be created directly within the Liferay platform using the Objects framework. These objects allow you to define fields, relationships, and behaviors similar to database tables, without requiring database-level programming. They seamlessly integrate into the Liferay ecosystem for managing application-specific data. 

Key Features of Liferay Objects:

  • System Objects: Default objects integrated with Liferay’s core functionality, such as Account, Organization, and User. 
  • Custom Objects: User-defined objects that extend the functionality of system objects to meet specific business requirements. 
  • Fields: Add custom data fields for your objects. 
  • Relationships: Establish links to system or custom objects. 
  • Actions: Set up custom workflows or business rules. 
  • Layouts: Design user-friendly interfaces. 
  • Views: Configure how data is displayed to users. 

Creating Custom Liferay Objects Using Asset Library and Account Workflow in Liferay:

Steps for Creating Custom Liferay Objects Using Asset Library and Account 

Creating custom objects in Liferay allows you to build tailored applications that meet specific business needs. Below are the step-by-step instructions for creating custom objects related to Asset Library and Account, and linking them for seamless management and display:  

Step 1: Accessing the Object Section: 

  • Ensure your Liferay server is running. 
  • Open your browser and navigate to localhost:8080. 
  • Go to the Control Panel and click on Objects. 



Step 2: Creating a New Custom Object

  1. In the Objects section, click the + icon to add a new custom object. 

     
  2. Provide the following details for the new object: 
  • Label: Identifies the object in the Objects admin and supported application contexts (e.g., Workflow, Display Page Templates, Forms). (e.g., Product).
  • Plural Label: Name for plural references (e.g., Products).
  • Object Name: Define the object name (e.g., Product). This cannot be changed once published.


3. Click Save to create a draft of the custom object.

Step 3: Adding Fields 

  1. Navigate to the Fields tab and click the + icon to add fields.

  2. Provide the Field Label, Field Name, and select the Field Type (e.g., Text, Decimal, Integer). 

     

3. Add fields to your Product object, such as: 

  • Product Name (Text) 
  • Product Description (Text Area) 
  • Price (Decimal) 
  • Stock Quantity (Integer)

Step 4: Editing Object Details

  1. Go to the Details section of your custom object. 

  2. Set Scope as "Site" 

  3. Set Panel Link as "Site Administration > People"


     

  4. Save and publish the object. 

Step 5: Establishing Relationships with System Objects 

Linking Custom Object with Account:

  1. Open the Account object and click on the + icon to add the relationship.


 

  1. Choose One-to-Many as the relationship type. 
  2. Choose Product as the object in the object field. 
  3. Click Save to establish the relationship.


 

Step 6: Creating an Account

  1. Navigate to the Control Panel and click on Accounts
  2. Add account information and addresses as needed. 

Click Save.

Step 7: Creating an Asset Library 

  1. Go to Global Menu > Applications > Asset Library. 

  2. Provide a name for the Asset Library.

  3. Add sites to the Asset Library. 

In the Documents and Media section, create a folder for Product images and upload relevant images.

Step 7: Adding a Product Image Field

  1. Navigate to Control Panel > Objects > Select Product. 
  2. Add a new field  
  3. Label: Product Image 
  4. Name: productImage 
  5. Field Type: Attachment 
  6. Request Files: Upload or Select from Documents and Media Item Selector.

 Step 8: Viewing Your Object 

  1. Go to the Site Navigation under People and select Product.

  2. Click on the '+' icon to add the object. 
  3. Fill in the details for each field, including uploading an image from the Asset Library. 

  1. Save the object. 

Step 9: Displaying the Object on a Web Page 

  1. Navigate to your site and drag and drop the Asset Publisher onto the page. 
  2. Click Configuration in the Asset Publisher.

  1. Set Asset Selection to Dynamic and select Asset Type: Product. 
  2. Save the configuration.  
  3. The Product object will now be visible on the web page. 
If you have any query, click here

 

Blogs