Pages

Wednesday 14 May 2014

Display profile pictures of all users in liferay?

Hi,

 Today I am going to show you how you can get Profile picture or Portrait of all users belonging to particular community or organization. Yet the problem sounds little bit easy but this post will save your time to make it correct in single attempt.


Problem :  I want to show a  slider to end user in which logo of all my clients will comes. It will look nice since it is dynamically generated means whenever a user will register & admin has assigned Client(Vendor) role to that particular  user.

Than his/her profile pic or in case of company a logo will automatically append in the existing slider....

Solution:

 1.  Make a simple portlet.

 2.  Put the following code in to your view.jsp


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@ page import="com.liferay.portal.model.User"%><%@ page import="java.util.List"%><portlet:defineObjects /><h1> Our Partners</h1><marquee behavior="scroll" direction="left"><%int i= UserLocalServiceUtil.getUsersCount();List<User> user =UserLocalServiceUtil.getUsers(0, i);String imgsrc="/image/user_male_portrait?img_id=";for(int j=1;j<i;j++){%><img src="<%=imgsrc+user.get(j).getPortraitId() %>"/>&#160; &#160; &#160; &#160;<%} %></marquee>


3. Deploy this portlet on liferay server.

4. Put ity on desire page.

5. It will show a slider(marquee) with profile pic of all users.6. Here is the output









Please keep sharing.... what you learn.


:)


No comments:

Post a Comment