Monday

Merging Layouts together

One of the common requirements that I have encountered is to Merge Layouts. Like people want on login all their community Layouts are shown along with the guest Layouts.
Or they want user layouts + org layouts together.

In this tutorial i would show how this can be achieved.

First Thought
  • How does all my Layouts get displayed as tabs in navigation?
  • How does it by default show the Home page as selected or the first tab as selected?
I found on debugging that above mentioned logic is written in ServicePreAction class. Here all the layouts that are to be displayed on a page as tabs are stored in themeDisplay along with one selected layout.

Where did I modify

I had to modify VelocityVariables in extension to merge my Layouts. Here you have a method named insertVariables where themeDisplay is inserted. Now the catch is
to manipulate on this themeDisplay object and set its Layouts and default layouts as we require.
This i had done using Extension environment.

  • In extension environment make a java file at the same package structure and name as of VelocityVariables
  • Find its insertVariables method
  • Find this line if (themeDisplay != null) {
  • Below that add your custom code to set its Layout. Like add this line below that
layouts = getLayouts(themeDisplay)
  • Now create a method that does the merging logic as under. Assuming that by default when user logs in he sees his Guest community pages and the requirement is to show users public pages along with that
private static List getLayouts(ThemeDisplay themeDisplay){
List layouts = themeDisplay.getLayouts;
return layouts;
}
  • The above piece of code will do nothing but what is happening already like showing the current layouts. Now we have to write our code in between the two lines such that the returning list of Layouts has our user layouts as well. So first we need user layouts. This can be achieved with following snippet
Group userGroup = themeDisplay.getUser().getGroup();
List userLayouts = LayoutLocalServiceUtil.getLayouts(userGroup.getGroupId(), false,LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
  • This will retrieve all the user layouts. Make sure this happens when user is logged in otherwise it may give exception since there is no user to retrieve their layouts. This can be achieved by wrapping the above snippet in a if condition which checks themeDisplay.isSignedIn().
  • The next step is pretty simple. You have to merge both layouts and return the same.
  • Hope that helps some. This may not be the ideal solution, if you have better solution please do share.

Checking Liferay 6 - Whats New Part I (Navigation)

Hi everyone
  • Today i thought why not check Liferay 6. So i went and downloaded Liferay 6 Tomcat bundle from sourceforge.

  • Created portal-ext.properties in ROOT/WEB-INF/classes

  • Added the following properties in it to connect to Mysql

jdbc.default.driverClassName=com.mysql.jdbc.Driver

jdbc.default.url=jdbc:mysql://localhost/lportal6? useUnicode=true&characterEncoding=UTF8&useFastDateParsing=false

jdbc.default.username=root

jdbc.default.password=root

  • Ran startup.bat in bin folder and it came up with the below page

Cool!!!

  • Logged in with test@liferay.com and password test

Wow first glimpse of Liferay 6!!!

So what do we have new here. I will check the general navigation today that is provided by default classic theme.

NAVIGATION

  • Single dock has been replaced with multiple dropdowns

  • My places previously in dock is replaced with Go To in top right. It takes you to by default

  • My Public Pages -- Your public pages

My Private Pages -- Your private pages

liferay.com -- Guest Public pages

  • Toggle Edit Controls finds a new separate home at top instead of a single dock
  • There is a new dropdown at top right named Manage which has following options

  • Page -- This is our old Manage Pages

  • Page Layout -- Same as Layout Template

  • SiteMap -- I found it same as Manage Page but by default taken to the second Tab named Children

  • Settings -- Settings is same as page settings available in Liferay 5.2.3 where in you can specify logo, virtual host, activate staging,etc

  • Control Panel -- Old Control panel


  • An Add drop with following options

  1. Page -- Same as Add Page

  2. Applications -- This lists commonly used portlets that can be directly add with option More which brings add application portlet

  • There is a small pin option that is to extreme right. I couldnt figure out what it pinned. At first I thought it would pin Navigation menu but navigation menu was by default pinned. After some clicks found out that it pinned the top most navigation menu, that is ones having option Add,Manage and Go To. Pretty cool!!!

Questions

  • I see two strips as below. On basic Navigation and the second one i am not sure, is it a navigation or Bread crumb portlet. How do i remove that?

Issues I found

  • I was getting Manage Pages temporarily not available occasionally with server log showing .NoSuchGroupException: No Group exists with the primary key 0. This happend sometimes when i clicked on children or look and feel.


  • I had liferay 5.2.3 instance logged in one tab of browser and liferay 6 in another tab IE 8. It kept me logging out from both if i tried to perform any action. Finally i had to switch to chrome for 5.2.3 instance and Liferay 6 in IE 8. Some problem with session i guess

BottomLine

I loved the new navigation that the default theme of Liferay has provided. It's very very interesting. Hard work by Liferay team really shows here. Kudos to them.

What next

I will check new portlets available in Liferay 6 next time.

PS

  • If you find anything new and interesting with Liferay 6 Navigation please mention it in a comment here.

  • By the time i finished posting this blog entry Liferay 6.0.1 was released. You can get if from sourceforge
  • Please pardon the mistakes and shabbiness of this blog entry

Tuesday

The First Step -- Installing Liferay Bundle

So here I go. My first step is to Install Liferay Bundle. I will use Liferay-Tomcat Bundle latest community edition that is Liferay 5.2.3

What You Need

Liferay Tomcat Bundle - Download it here
Java - Download it here
Steps

  • Install JDK
  • Right Click My Computer and click on Properties. Click on Advanced Tab and click on Environment Variables Button. You will see System Variables there. Click "New" under it. Set Variable Name = JAVA_HOME and Variable Value = path till jdk like C:\Program Files\Java\jdk1.6.0_18
  • In System Variables Section you will see a variable named Path. Select that and click on Edit. Add this at the start %JAVA_HOME%\bin;
  • Go to command prompt and type java or javac. It should show a list of command options to go with particular java or javac.
  • Installing Tomcat bundle is very easy one. Just unzip the bundle that you have downloaded. Go to the path C:\liferay\bundles\liferay-portal-5.2.3\tomcat-6.0.18\bin and double click startup.bat.
  • Server should start up as shown in the screen below and it will automatically open your default browser with liferay homepage.
Hurray!!!