Wednesday 19 September 2012

Creating User Page, Applying theme and Adding portlet to them

Creating User Page, Applying theme and Adding portlet to them

The following post tells you how to create a user page(layout), add portlets to them and apply some theme.

First of all you have to add the following properties in portal-ext.properties file, (I'm just filling example data, you can fill as per your requirements:)


layout.id=2_columns_i
user.theme=sevencogs

portlet.id=20

Now call the following function as per the implementation logic. Code is kinda self explanatory,a nd I've already put comments between them:



 public static void createUserLayout(User user){

 try{

  ServiceContext serviceContext = new ServiceContext();

  Log.info("Creating User Homepage for "+user.getName()+" with name " + user.getName() + "-home");

  // Layout assignment for user pages. Values will be provided by Properties.

  String name = user.getName() + "-home";

  Layout layout = LayoutLocalServiceUtil.addLayout(user.getUserId(), user.getGroup().getGroupId(), true, 0, name, name,"", LayoutConstants.TYPE_PORTLET, false, StringPool.BLANK, serviceContext);

  // Adding portlets

  String typeSettings = "layout-template-id=" + PropsUtil.get("homepage.layout.id") + "\n";

  String portletIds = PropsUtil.get("portlet.id");

  typeSettings += "column-1=" + portletIds + "\n";

  layout.setTypeSettings(typeSettings);

  // Applying theme

  String themeId = PropsUtil.get("user.theme");

  if(themeId != null && !themeId.equals("")){

   layout.setThemeId(themeId);

   layout.setColorSchemeId("01");

  }

  LayoutLocalServiceUtil.updateLayout(layout);

 }catch(Exception e){

  e.printStackTrace();

 }

 }







Source : http://www.apoorvaprakash.in/2012/06/creating-user-page-applying-theme-and.html

16 comments:

  1. Hey very nice,want to read more from you...Keep It Up!!!
    Useful Link-Gmail Tech Support

    Thanks

    ReplyDelete
  2. Helpful information!!!

    Click on the link to get theGmail Tech Support

    Thanks

    ReplyDelete
  3. If you are a customer of Norton Antivirus Support then it is definite that a better antivirus services will be provided to you.

    Norton Antivirus Security Scan | McAfee Antivirus Security Scan

    ReplyDelete
  4. Adwords Promotional Code provides expert PPC services for almost all business categories and from all various verticals including travel and technology with focus on ppc for technical support.

    ReplyDelete
  5. To make our computer in better condition and free from any risk it is essential to give tech support to our PC.

    Norton Tech Support | McAfee Tech Support

    ReplyDelete